Page 55 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 55

Database Management Systems/Managing Database




                    Notes          Query (e): Find all the employees whose department name starts with ‘pac’.
                                   Solution:
                                   SELECT *
                                   FROM     Employee E, Department D

                                   WHERE    E.eid = D.Dept_Managerid AND
                                   D.Dname  LIKE ‘pac %’

                                   3.7.2  Insert Command

                                   The insert statement is used to insert or add a row of data into the table.
                                   To insert records into a table, enter the key words insert into followed by  the table name,
                                   followed by an open parenthesis, followed by a list of column names separated by commas,
                                   followed by a closing parenthesis, followed by the keyword values, followed by the list of
                                   values enclosed in parenthesis. The values that you enter will be held in the rows and they will
                                   match up with the column names that you specify. Strings should be enclosed in single quotes,
                                   and numbers should not.
                                   insert into “tablename”
                                   (first_column,...last_column)

                                   values  (first_value,...last_value);
                                   In the example below, the column  name first will match  up with the value ‘Luke’, and  the
                                   column name state will match up with the value ‘Georgia’.


                                          Example: insert into employee
                                                 (first, last, age, address, city, state)

                                                 values (‘Luke’, ‘Duke’, 45, ‘2130 Boars Nest’,
                                                 ‘Hazard Co’, ‘Georgia’);




                                     Notes  All strings should be enclosed between single quotes: ‘string’

                                   3.7.3  Update Command


                                   Update Rows

                                   The syntax for this command is
                                   update tablename set colname1=colvalue where colname2=colvalue;


                                          Example: update Student set Name = ‘Ajay’ where id = 2;
                                   This command has updated the Name ‘Rose’ in Student table whose id is 2.








          48                                LOVELY PROFESSIONAL UNIVERSITY
   50   51   52   53   54   55   56   57   58   59   60