Page 345 - TP_IT_V1.0_C10_flipbpookl
P. 345

•  The deletion of information from the table (not deleting the column), using DELETE
                 •  The modification of information stored in the table (not modifying the data type of column), using UPDATE
                 The syntax for inserting a new record in the table is as follows:

                 INSERT INTO <Table Name> [(<Col1>,<Col2>,... <Col N>)]
                 VALUES ((<Col1 Value>,<Col2 Value>,... <Col N Value>);
                 For example,

                 INSERT INTO student VALUES (14,'Jaya Kapoor',7800,'2008-03-08',78, 9);
                 INSERT INTO student VALUES (35,'Sikha Arora',8800,'2004-12-15',87, 5);
                 INSERT INTO student VALUES (8,'Aparna Aneja',9000,'2006-09-24',92, 6);
                 INSERT INTO Student VALUES (12,'Debrath Singh',8600,'2010-10-27',80,'10A');
                 The syntax for modifying the existing content of the table is as follows:

                 UPDATE <Table Name>
                 SET <Col1>=<Value1> [,<Col2>=<Value2>,... <Col N>=<Value N>]
                 [WHERE <Condition>];
                 For examples,

                 UPDATE STUDENT SET MARKS=92 WHERE CLASSSEC='10A' ;
                 UPDATE STUDENT SET CLASSSEC='11C' WHERE NAME='JAYA KAPOOR';
                 UPDATE STUDENT SET CLASSSEC='9D' WHERE ROLLNO=35;
                 UPDATE STUDENT SET CLASSSEC='10A' WHERE FEES=9000;
                 SELECT * FROM STUDENT;
                 +--------+---------------+------+------------+-------+----------+
                 | RollNo | Name          | Fees | DOB        | Marks | ClassSec |
                 +--------+---------------+------+------------+-------+----------+
                 |     14 | Jaya Kapoor   | 7800 | 2008-03-08 |    78 | 11C      |
                 |     35 | Sikha Arora   | 8800 | 2004-12-15 |    87 | 9D       |
                 |      8 | Aparna Aneja  | 9000 | 2006-09-24 |    92 | 10A      |
                 |     12 | Debrath Singh | 8600 | 2010-10-27 |    92 | 10A      |
                 +--------+---------------+------+------------+-------+----------+
                 To display Name and fees of the student with increased fees by Rs 250.

                 SELECT NAME, FEES+250 FROM STUDENT;
                 +---------------+----------+
                 | NAME          | FEES+250 |
                 +---------------+----------+
                 | Jaya Kapoor   |     8050 |
                 | Sikha Arora   |     9050 |
                 | Aparna Aneja  |     9250 |
                 | Debrath Singh |     8850 |
                 +---------------+----------+
                 The syntax for deleting a row/rows from a table is as follows:

                 DELETE FROM <Table Name> [WHERE <Condition> ];
                 For example,
                 DELETE FROM Student WHERE RollNo=12
                 To delete all rows of a table (Does not delete the structure of the table)

                 DELETE FROM Student;
                 Note: To run these queries, click on the Tools menu and then select the SQL option. The Execute SQL Statement dialog
                 box opens. Type the SQL command and click on the Execute button.

                                                                        Database Management System using LibreOffice Base  343
   340   341   342   343   344   345   346   347   348   349   350