SELECT-to retrive & display data from one or more data tables,extemly powerful and is the most frequently used this command.
Consider this Simple Example
Table Student
Let us see how to get Information of Praneeth 's
SELECT Mark
FROM `student`
Output maybe
INSERT Command
Syntax
INSERT INTO table[(collist)] values(dataValues)
This formatof the INSERT Statement allows a single row to be inserted into a named table.Table is a base.table or a view and colList is a list of one/more comma separated column names.The collist list ia optional.if omitted,SQL assumes a list column in the order in which the table was created.if specified,then any columns that are ommited from the list must have been declared NULL columns when table was created or the DEFAULT option was used when creating the column.The dataValueList must match the colList as Follows.
- The number of items in each list must be same .
- There must be a direct correspondence in the position of Items in the 2 lists,so that the 1stitem in dataValuesList applies to the 1st item in colList and so on.
- The data type of each item in dataValuesList must be compatible with the data type of the corresponding column
INSERT INTO BRANCH VALUES('55','Dreams road','Colombo');
it is also possible to insert values only to the mandatory columns that we are inserting data in to.
Example
INSERT INTO BRANCH ('brnch no','city')VALUES('b8','Colombo');
Apart from this ,it is possible to insert data to the columns branchNO and city while explicity assigning the street to null.
Example
INSERT INTO BRANCH VALUES('b8',NULL,'Colombo');
Another important from of the INSERT statement is inserting multiple rows from one or more tables to another
Sysntax
UPDATE Table [(colList)]
set cil1=dataValue1[,col2=datavalue2..]
[WHERE search condition]
The where clause is optional.if omitted,the named columns are updated for all rows and if specified,only those rows that satisfy the searchCondition are updated.The new data values must be compatible with the data type of the corresponding columns
Example
UPDATE staff SET sallary =sallary+1000 where position='Spervisor'
DELETE command
Sysntax
DELETE FROM table
[WHERE searchCondition] Here ,the Table can be any base table or a view.The search condition is Optional.If ommited,all rows will be deletd from the table.This does not delete the table it self.If the SearchCondition the Condition will be deleted