0% found this document useful (0 votes)
51 views

DBMS Lab Exam

The document discusses the different languages used in SQL - DDL, DML, TCL, DCL - and their uses. It also covers various SQL operators, joins, and views. DDL is used to define and modify database objects like tables through commands like CREATE, ALTER, RENAME, DROP. DML allows manipulating data within tables through INSERT, DELETE, UPDATE, SELECT. TCL controls transactions with COMMIT, ROLLBACK, SAVEPOINT. DCL manages user data access with GRANT, REVOKE privileges.

Uploaded by

Komal nadakuditi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

DBMS Lab Exam

The document discusses the different languages used in SQL - DDL, DML, TCL, DCL - and their uses. It also covers various SQL operators, joins, and views. DDL is used to define and modify database objects like tables through commands like CREATE, ALTER, RENAME, DROP. DML allows manipulating data within tables through INSERT, DELETE, UPDATE, SELECT. TCL controls transactions with COMMIT, ROLLBACK, SAVEPOINT. DCL manages user data access with GRANT, REVOKE privileges.

Uploaded by

Komal nadakuditi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

DDL(DATA DEFINITION LANGUAGE)

1) Create
create table tablename(col1 datatype(size) , col2
datatype(size)...);

2)ALter ADD
alter table tablename ADD columnname datatype(size); to
chech whether the col is add or not : Desc tablename ;

....ALTER DROP
alter table tablename drop column columnname ;

....ALTER RENAME
alter table tablename rename col oldname to new col name ;

....ALTER MODIFY
alter table tablename modify address varchar2(15) ;

3)RENAME
Rename old tablename to new_tablename ;

4)DROP
Drop table tablename ;

5) TRUNCATE
truncate table tablename ;

DML(DATA MANIPULATION LANGUAGE)

1) INSERT
Insert into tablename values(eno,'ename',sal);

2) DELETE
Delete from tablename where columnname='value'; AND Delete table
tablename ;

example:Delete from emp where eno=2;

3) UPDATE
Update tablename set columnname=value;

example:Update emp set salary=6000 where eno=3;

4) SELECT
* indicates all the records in the table

Example: Select * from emp where sal>3000 ;

TCL(TRANSACTION CONTROL LANGUAGE)

1) COMMIT : IT PERMANENTLY STORES THE DATA IN A DATABASE


syntax : commit

2) SAVEPOINT :

syntax : savepoint savepoint name ;

3) ROLLBACK :

syntax : Rollback

DCL(DATA CONTROL LANGUAGE)

CREATING A USER IN DATABASE


.....user created.....

Grant access priviliges to username ;


...... Grant succeded......

1) GRANT
Grant insert , delete privilege to username ;
Grant all access privileges to username ;

2) REVOKE
Revoke delete privileges ;
Revoke username ;

SET OPERATORS

1)ARTHEMETIC OPERATORS : + , - , * , % , / . syntax : select 2 + 3 ;


2)LOGICAL OPERATORS : AND , NOT , OR . syntax : select eno , dept from emp
where sal > 3000 whose dept = 'CSE' AND/OR/NOT 'ECE' ;
3)CONDITIONAL OPERATORS: > , < , >= , <= , == , != , = . syntax : select
eno , dept from emp where sal > 3000 whose dept = 'CSE' >/</>=/<=/==/!=/= 'ECE' ;
4)BITWISE OPERATRS: & , ! , && , !! , ^ . syntax : select a & b ;
5)BOOLEAN OPERATORS: TRUE , FALSE .

SQL OPERATORS

1) UNION select * from emp union select * from emp1;

2) UNION ALL select * from emp union all select * from emp1 ;

3) INTERSECT select * from emp intersect selct * from emp1 ;

4) MINUS select * from emp minus select * from emp 1 ;

JOINS

1) INNER JOIN select table1.col1 , table2.col1,.....


from table1
inner join table2 on table1.matching_col=table2.matching_col ;

2) LEFT JOIN select table1.col1 , table2.col1,.....


from table1
left join table2 on table1.matching_col=table2.matching_col ;

3) RIGHT JOIN select table1.col1 , table2.col1,.....


from table1
right join table2 on table1.matching_col=table2.matching_col ;

4) FULL JOIN select table1.col1 , table2.col1,.....


from table1
full join table2 on table1.matching_col=table2.matching_col ;

VIEWS

1) CREATING VIEW FOR ONE TABLE create view viewname as


select col1 , col1 from tablename
where condition ;

2) CREATING VIEW FOR TWO TABLES create view viewname as


select tablename1.col1 , tablename1.col2,......
tablename2.col1 , tablename2.col2,.....
from tablename1 , tablename2
where condition ;

You might also like