Previously, we've been talking about the various commands of sql used in oracle database programming. Now we'll continue our talks with the next category of commands. they are the DML commands. DML stands for Data Manipulation Language commands. the commands that come under this category are:
This command is called a query, its basically used to retireve the data present in the table ofour data base. It has the following full syntax:
Syntax:
SELECT column_names FROM table_name [WHERE condition];
This is in case of a varied number of rows. If we want to retrieve the entire rows of a given table, we simply replace our column_names by a * .
SELECT * FROM table_name [WHERE condition];
Example:
1. SELECT sno,sname,sec FROM student;
2. SELECT* FROM student;
Although SELECT command can be used in more lengthy manner, we'll restrict our syntax to here for now. we'll have a complete syntax after we have further more commands.
INSERT:
This is a command that can be used for adding rows to a table. we use this to add a row having all the attributes to a table. the unknown attributes are left with a NULL, that can be replaced later.
The syntax of an INSERT command is:
Syntax:
INSERT INTO table_name VALUES ( value_1, value_2, value_3,...);
Example:
INSERT INTO student VALUES (1101, ram, s2);
UPDATE:
this command can be used to modify an old value of a table with a new value, obviously used in replacements of entries. The syntax for this command is:
Syntax:
UPDATE TABLE table_name SET column_value=new_value WHERE column_value=old_new;
Example:
UPDATE TABLE student SET sno=1102 WHERE sno=1101;
DELETE:
this command deletes a row or a number of rows from the table, if we want to retain the table structure clearing all the entries, we can use * in place of the column names. the syntax of the command will be as follows:
Syntax:
DELETE column_names FROM table_name WHERE condition;
Example:
DELETE sno,sname FROM student WHERE sno=1101;
Summary:
- Select
- Insert
- Update
- Delete
This command is called a query, its basically used to retireve the data present in the table ofour data base. It has the following full syntax:
Syntax:
SELECT column_names FROM table_name [WHERE condition];
This is in case of a varied number of rows. If we want to retrieve the entire rows of a given table, we simply replace our column_names by a * .
SELECT * FROM table_name [WHERE condition];
Example:
1. SELECT sno,sname,sec FROM student;
2. SELECT* FROM student;
Although SELECT command can be used in more lengthy manner, we'll restrict our syntax to here for now. we'll have a complete syntax after we have further more commands.
INSERT:
This is a command that can be used for adding rows to a table. we use this to add a row having all the attributes to a table. the unknown attributes are left with a NULL, that can be replaced later.
The syntax of an INSERT command is:
Syntax:
INSERT INTO table_name VALUES ( value_1, value_2, value_3,...);
Example:
INSERT INTO student VALUES (1101, ram, s2);
UPDATE:
this command can be used to modify an old value of a table with a new value, obviously used in replacements of entries. The syntax for this command is:
Syntax:
UPDATE TABLE table_name SET column_value=new_value WHERE column_value=old_new;
Example:
UPDATE TABLE student SET sno=1102 WHERE sno=1101;
DELETE:
this command deletes a row or a number of rows from the table, if we want to retain the table structure clearing all the entries, we can use * in place of the column names. the syntax of the command will be as follows:
Syntax:
DELETE column_names FROM table_name WHERE condition;
Example:
DELETE sno,sname FROM student WHERE sno=1101;
Summary:
No comments:
Post a Comment