3. FIRSTUP
CONSULTANTS
CONTINUE…
3
• Syntax:
< create table table name <field 1> < data type>
• Rename < rename table name to new name>
Rename emp to emp2
Select * from emp 2:
• Alter < alter table = table name add column name , data type.
< alter table emp2 add eadd varchar (30)
• Truncate = truncate = table name
Table record delete not delete table
< truncate table emp2>
< desc emp2>
• Drop = drop table , table name
• Permanent delete
• < create table of student >
• < drop table student>
• <desc student>
4. FIRSTUP
CONSULTANTS
DML ( DATA MANIPULATION LANGUAGE)
4
• Insert
• Update
• Delete
• Syntax:
• < insert into < table name > values
• < create table>
• < insert into singer values ( asim azhar , Lahore):
• < update < table> set < field> = < update> where < field> = < reference data>
• < update singer set name = atif aslam , Lahore
• < delete from <table name>
• <delete from singer>
• <Delete from singer where asim azhar 1> condition statement
5. FIRSTUP
CONSULTANTS
DCL ( DATACONTROL LANGUAGE)
5
• Privilege is a permission given by database.
• SQL , DCL command deals with privileges.
• Grant: It helps to provide any kind of access to any user.
• Revoke: It is used to take back the access from users.
• syntax: < create database user name system >
• < select table>
• < create user arif identified by pwd;>
• < connect to user arif and password>
• < grant connect to arif > we give the privilege and give grant
• < connect >
• <revoke delete on select table>
• < revoke all on select table>
6. FIRSTUP
CONSULTANTS
DQL (DATAQUERY LANGUAGE)
6
• It is used to retrieve information from database.
• It has only one select command.
• Syntax :
• Select * from < table name>
• < create table>
• < select * from stu;>
• < select * from stu where roll=2>
7. FIRSTUP
CONSULTANTS
TCL (TRANSACTION CONTROL LANGUAGE)
7
• It control the transaction of database it has three commands.
• Commit
• Rollback
• Save point
Syntax:
• Commit command: the use of commit command to store permanent record in server.
• Create table < commit < commit complete>
• Rollback : one step back if you use rollback query after commit doesn’t not give output
• < insert into player values(3, ‘ rohit’, 264);
• < rollback they take it back and have 2 rows.
• Save point < save point we have 5 records>
• < rollback + save point > we see 10 records
• < save point A :>
• < insert 5 records>
• < save point B>
• < we have 10 records>