Update OS/bash/Week4/SQLPlus.md

This commit is contained in:
Aadit Agrawal 2025-01-21 15:14:25 +05:30
parent b9f4d55eba
commit f1c2ffe939

View File

@ -72,6 +72,13 @@ SQL> desc PARTICIPATED
REGNO NOT NULL VARCHAR2(20)
REPORT_NUMBER NOT NULL NUMBER(38)
DAMAGE_AMOUNT NUMBER(38)
```
Now, we enter values.
```sql
SQL> insert into person values(1234,'Rohan','Delhi India');
1 row created.
SQL> select * from person;
@ -143,4 +150,188 @@ NAME
ADDRESS
--------------------------------------------------------------------------------
Manipal India
```
```
Now, we modify the varchar sizes so that we can fix the display formatting.
```sql
SQL> alter table person modify address varchar (30);
Table altered.
SQL> select * from person;
DRIVER_ID# NAME
------------------------------ ----------------------------------------
ADDRESS
------------------------------
1234 Rohan
Delhi India
1235 Rohit
Banglalore India
1236 Ramesh
Baharashtra India
DRIVER_ID# NAME
------------------------------ ----------------------------------------
ADDRESS
------------------------------
1237 Saarthak
Manipal India
SQL> alter table person modify driver_id# varchar (4);
Table altered.
SQL> alter table person modify name varchar (10);
Table altered.
SQL> select * from person;
DRIV NAME ADDRESS
---- ---------- ------------------------------
1234 Rohan Delhi India
1235 Rohit Banglalore India
1236 Ramesh Baharashtra India
1237 Saarthak Manipal India
```
Data updation.
```sql
SQL> update person set address='Maharashtra India' WHERE driver_id# = 1236;
1 row updated.
SQL> select * from person;
DRIV NAME ADDRESS
---- ---------- ------------------------------
1234 Rohan Delhi India
1235 Rohit Banglalore India
1236 Ramesh Maharashtra India
1237 Saarthak Manipal India
SQL> insert into person values(1238, 'Amogh', 'Muzaffarnagar');
1 row created.
```
### Listing Tables
```sql
SQL> select table_name from user_tables;
TABLE_NAME
--------------------------------------------------------------------------------
ACCIDENT
CAR
OWNS
PARTICIPATED
PERSON
```
More Data Entry.
```sql
SQL> insert into car values('ABCD0001','Celtos',3);
1 row created.
SQL> insert into car values('EFGH2001','Ferrari',32);
1 row created.
SQL> insert into car values('DSDS0001','Urus',5);
1 row created.
SQL> insert into car values('ABCD4001','Honda City',1);
1 row created.
SQL> insert into car values('HFSP5601','mini cooper',7);
1 row created.
SQL> select * from car;
REGNO MODEL YEAR
-------------------- ------------------------------ ----------
ABCD0001 Celtos 3
EFGH2001 Ferrari 32
DSDS0001 Urus 5
ABCD4001 Honda City 1
HFSP5601 mini cooper 7
SQL> insert into accident values(0001,'01-Jan-2024','Delhi India');
1 row created.
SQL> select * from accident;
REPORT_NUMBER ACCD_DATE LOCATION
------------- --------- --------------------------------------------------
1 01-JAN-24 Delhi India
SQL> insert into accident values(0003,'29-feb-2024',' India');
1 row created.
SQL> insert into accident values(0004,'11-Oct-1993',' Daman and Diu India');
1 row created.
SQL> insert into accident values(0005,'31-march-2200',' Gujrat India');
1 row created.
SQL> insert into accident values(12,'17-july-2900',' karnataka India');
1 row created.
SQL> select * from accident;
REPORT_NUMBER ACCD_DATE LOCATION
------------- --------- --------------------------------------------------
1 01-JAN-24 Delhi India
3 29-FEB-24 India
4 11-OCT-93 Daman and Diu India
5 31-MAR-00 Gujrat India
12 17-JUL-00 karnataka India
SQL> insert into owns values(1234,'ABCD0001');
1 row created.
SQL> insert into owns values(1235,'EFGH2001');
1 row created.
SQL> insert into owns values(1236,'DSDS0001');
1 row created.
SQL> insert into owns values(1237,'ABCD4001');
1 row created.
SQL> insert into owns values(1238,'HFSP5601');
1 row created.
SQL> select * from owns;
DRIVER_ID# REGNO
------------------------------ --------------------
1234 ABCD0001
1235 EFGH2001
1236 DSDS0001
1237 ABCD4001
1238 HFSP5601
```
Note:
```sql
SQL> @<FILEPATH>/filename.sql
```
will import the commands from a doc and run them.