Structured Query Language(SQL) as we all know is the database language by the use of which we can perform certain operations on the existing database and also we can use this language to create a database. SQL uses certain commands like Create, Drop, Insert etc. to carry out the required tasks.
These SQL commands are mainly categorized into four categories as discussed below:
DML (Data Manipulation Language):
Data Manipulation Language (DML) statements or commands are used for managing data within tables.Some commands of DML are:
INSERT – insert data into a table.
UPDATE – updates existing data within a table.
DELETE – deletes all records from a table, the space for the records remain.
SELECT – retrieve data from the a database.
[1]INSERT:
The insert statement is used to add new row to a table.In insert commands, they have 5 syntax are as follows:SYNTAX 1: insert into table_name
values(value1,value2,.....,valuen);
SYNTAX 2: insert into table_name(column_Name1,column_Name2,column_Name3)
values(value1,value2,value3);
SYNTAX 3: insert into table_name(column_Name1,column_Name2,....)
values(value1,value2,....);
SYNTAX 4: insert into table_name
values(&column_Name1,&column_Name2,........,&column_Namen);
SYNTAX 5: insert into table_name
select * from exiting table_name;
EXAMPLE: insert into emp
values(1,'ram');
NOTE: The inserted values must match the table structure exactly in the number of attributes and the data type of each attribute. Character type values are always enclosed in single quotes; number values are never in quotes; date values are often (but not always) in the format ‘yyyy-mm-dd’ (for example, ‘2006-11- 30’).The syntax 4 is not run on 'Oracle Database 10g Express Edition'. This syntax run on 'Run SQL Command Line'are the option of 'Oracle Database 10g Express Edition'.
[2]UPDATE :
The update statement is used to change values that are already in a table.SYNTAX: update table_name
set column_Name = new_value
where condition;
EXAMPLE: update emp
set empname = 'rakesh'
where empno=11;
NOTE: The update expression can be a constant, any computed value, or even the result of a SELECT statement that returns a single row and a single column.
[3]DELETE :
The delete statement deletes row(s) from a table.SYNTAX: delete from table_name
where condition;
EXAMPLE: delete from emp
where empno=11;
NOTE: If the WHERE clause is omitted, then every row of the table is deleted that matches with the specified condition.
[4] SELECT :
The SELECT statement is used to form queries for extracting information out of the database.SYNTAX 1: select * from table_name
where condition;
SYNTAX 2: select column_Name1,column_Name2 from table_name
where condition;
EXAMPLE: select * from emp or select empname from emp
where empname='rajesh'; where salary< 60000;
Apart from these statements, some statements are also used to control the transaction made by DML statements. The commands used for this purpose are called Transaction Control (TCL) statements. It allows statements to be grouped together into logical transactions.
We are learn TCL and DCL COMMAND in the next tutorial.
If you liked the tutorial then don’t forget to comment and share!
0 comments:
Post a Comment