Department Name Computer Application
Department Name Computer Application
DDL
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 8
CREATE command
It is used to create a new table in the database.
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);
Example:
CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), DOB
DATE);
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 9
DROP command
It is used to delete both the structure and record stored in the table.
Syntax
DROP TABLE ;
Example
DROP TABLE EMPLOYEE;
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 10
ALTER Command
It is used to alter the structure of the database. This change could be either
to modify the characteristics of an existing attribute or probably to add a new
attribute.
Syntax:
To add a new column in the table
ALTER TABLE table name ADD column_name COLUMN-definition;
To modify existing column in the table:
ALTER TABLE MODIFY(COLUMN DEFINITION....);
EXAMPLE
ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 11
TRUNCATE command
TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE EMPLOYEE;
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 12
DML command
Command Description
Used to query or fetch selected fields or columns from a database
SELECT
table
INSERT Used to insert new data records or rows in the database table
Used to set the value of a field or column for a particular record to
UPDATE
a new value
DELETE Used to remove one or more rows from the database table
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 13
select
SELECT command or statement in SQL is used to fetch data records from the database
table and present it in the form of a result set. It is usually considered as a DQL
command but it can also be considered as DML.
The basic syntax for writing a SELECT query in SQL is as follows :
SELECT column_name1, column_name2, … FROM table_name WHERE condition_
expression;
The parameters used in the above syntax are as follows :
column_name1, column_name2, … : Specify the column_names which have to be
fetched or selected for the final result set.
table_name: Specify the name of the database table from which these results have
to be fetched.
condition_expression: Specify the condition expression for filtering records for the
final result set.
Here are a few examples to illustrate the use of SELECT command.
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 14
INSERT
INSERT commands in SQL are used to insert data records or rows in a database
table. In an INSERT statement, we specify both the column_names for which the
entry has to be made along with the data value that has to be inserted.
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Sakshi dubey Unit 1 15
UPDATE
UPDATE command or statement is used to modify the value of an existing column
in a database table.
The syntax for writing an UPDATE statement is as follows :
UPDATE table_name SET column_name_1 = value1, column_name_2 = value2, ...
WHERE condition;
# Structure will be as per the nomenclature of the program and will be finalized in
consultation with Head of Dept/Head of Institution.
Faculty Name Unit 1 17
TCL (transaction Control Language)
Q&A
Faculty Name Unit 1 20