From 01755843a4e5c2acc2af6b813a14f29532751d8c Mon Sep 17 00:00:00 2001 From: Aadit Agrawal Date: Tue, 21 Jan 2025 15:28:23 +0530 Subject: [PATCH] Update OS/bash/Week4/SQLPlus.md --- OS/bash/Week4/SQLPlus.md | 83 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/OS/bash/Week4/SQLPlus.md b/OS/bash/Week4/SQLPlus.md index 3743ec7..343ac06 100644 --- a/OS/bash/Week4/SQLPlus.md +++ b/OS/bash/Week4/SQLPlus.md @@ -334,4 +334,85 @@ Note: ```sql SQL> @/filename.sql ``` -will import the commands from a doc and run them. \ No newline at end of file +will import the commands from a doc and run them. + +Saved commands into `participated.sql`. + +```sql +SQL> @C:\Users\student\Downloads\participated.sql + +1 row created. + + +1 row created. + + +1 row created. + + +1 row created. + + +1 row created. + + +SQL> select * from participated; + +DRIVER_ID# REGNO REPORT_NUMBER DAMAGE_AMOUNT +------------------------------ -------------------- ------------- ------------- +1234 ABCD0001 1 10000 +1236 DSDS0001 3 150 +1237 ABCD4001 4 799 +1238 HFSP5601 5 1500 +1238 HFSP5601 12 95500 +``` + +Updating data entries: +```sql +SQL> update participated set damage_amount=25000 where regno='HFSP5601' and report_number=12; + +1 row updated. + +SQL> update participated set damage_amount=25000 where regno='ABCD0001' and report_number=12; + +0 rows updated. + +SQL> select * from participated; + +DRIVER_ID# REGNO REPORT_NUMBER DAMAGE_AMOUNT +------------------------------ -------------------- ------------- ------------- +1234 ABCD0001 1 10000 +1236 DSDS0001 3 150 +1237 ABCD4001 4 799 +1238 HFSP5601 5 1500 +1238 HFSP5601 12 25000 +``` +### Dropping an attribute +```sql +SQL> alter table Participated + + 2 drop constraint fkey3paricipated; + +Table altered. + +SQL> select * from participated; + +DRIVER_ID# REGNO REPORT_NUMBER DAMAGE_AMOUNT +------------------------------ -------------------- ------------- ------------- +1234 ABCD0001 1 10000 +1236 DSDS0001 3 150 +1237 ABCD4001 4 799 +1238 HFSP5601 5 1500 +1238 HFSP5601 12 25000 +``` + +Adding back the attribute. + +```sql +SQL> alter table Participated + 2 add constraint fkey3participated foreign key(report_number) references accident(report_number) + 3 on delete cascade; + +Table altered. +``` +