DDL, DML, DCL, DQL, TCL 1
DDL, DML, DCL, DQL, TCL 1
LANGUAGE
Name : AJITHRAM
EMP ID :OM2116262
ORACLE :
Oracle sql developer is an integrated development
environment for working with sql in oracle databases
SQL :
o SQL commands are instructions. It is used to communicate with the database.
It is also used to perform specific tasks, functions, and queries of data.
o SQL can perform various tasks like create a table, add data to tables, drop the
table, modify the table, set permission for users.
o DDL changes the structure of the table like creating a table, deleting a table,
altering a table, etc.
o All the command of DDL are auto-committed that means it permanently save
all the changes in the database.
o CREATE
o ALTER
o DROP
o TRUNCATE
Syntax:
ALTER: 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.
ADD :
Syntax:
Modify :
* The alter table statement is also used to add and drop various
constraints on an existing table
1.alter table dcl modify(place varchar2(15));
Drop :
The drop column command is used to delete a column in an
existing table.
Syntax :
1. alter table ncl drop (place);
Rename:
Columns can be also be given new name with the use of ALTER TABLE. QUERY:
Change the name of column NAME to FIRST_NAME in table Student.
Syntax :
1. drop table ncl;
Truncate:
TRUNCATE is a DDL(Data Definition Language) command and is used to
delete all the rows or tuples from a table
Syntax :
1.Truncate table test_table;
Rename :
Use the ALTER TABLE RENAME command to rename column names.
Syntax :
1. Rename ncl to pcl;
Output:
o DML commands are used to modify the database. It is responsible for all form
of changes in the database.
o The command of DML is not auto-committed that means it can't permanently
save all the changes in the database. They can be rollback.
Insert
Update
Delete
a. INSERT:
The INSERT statement is a SQL query. It is used to insert data into
the row of a table.
Syntax:
UPDATE :
Syntax:
output:
DELETE :
Syntax:
Output :
o COMMIT
o ROLLBACK
o SAVEPOINT
1.commit;
Output :
b. Rollback:
Rollback command is used to undo transactions that have not
already been saved to the database.
Syntax:
1. ROLLBACK;
Output :
c. SAVEPOINT:
It is used to roll the transaction back to a certain point without
rolling back the entire transaction.
Syntax:
1. SAVEPOINT SAVEPOINT_NAME;
o Grant
o Revoke
Example
1.
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;
Example
1. REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
o SELECT
a. SELECT:
Syntax:
1. SELECT expressions
2. FROM TABLES
3. WHERE conditions.