Professional Documents
Culture Documents
500000;
grant all on IBM_DB to twm;
/* SET TABLE*/
create set table DEMO_SET(id int,name varchar(10));
insert into DEMO_SET values(1,'ARAVIND');
select * from DEMO_SET;
insert into DEMO_SET values(1,'ARAVIND');
/* MULTISET TABLE*/
create multiset table DEMP_MS(id int,name varchar(10));
insert into DEMP_MS values(1,'ARAVIND');
select * from DEMP_MS;
insert into DEMP_MS values(1,'ARAVIND');
/* VOLATILE TABLE*/
create volatile table demo_volatile(id int,name
varchar(10));
create volatile table demo_volatile1(id int,name
varchar(10)) ON COMMIT PRESERVE ROWS;
insert into DEMO_volatile1 values(1,'ARAVIND');
select * from DEMO_VOLATILE1;
/* DDL STATEMENTS*/
-- CREATE TABLE:
create table employee(empno int,ename varchar(10),sal
int);
--ALTER COMMAND WITH SPECIFIC OPERATIONS:
-- ADD COLUMN:
alter table employee add job varchar(20);
-- MODIFY THE EXISTING DATATYPE:
alter table employee add job varchar(30);
--RENAME A EXISTING COLUMN OF TABLE:
alter table employee rename sal to salary;
--DROPPING AN EXIXTING COLUMN:
alter table employee drop salary;
--RENAME TABLE:
rename table employee to emp;
rename table emp to employee;
--DML COMMAND:
--INSERT:
insert into employee values(1,'ARAVIND','MANAGER');
insert into employee values(2,'BALAJI','VP');
insert into employee values(3,'CHANDHRU','KING');
insert into employee values(4,'DINESH','PRESIDENT');
insert into employee values(5,'AZEEM','DPTMANAGER');
select * from employee;
--COPY OF A TABLWE WITH DATA:
create table emp_test as(select * from employee) WITH
DATA;
select * from emp_test;
--COPY OF A TABLE WITH NO DATA:
create table emp_test1 as(select * from employee) WITH
NO DATA;
select * from emp_test1;
--TRUNCATE TABLE RECORS:
delete emp_test all;
--DROP TABLE:
DROP table emp_test1;
--DML COMMANDS:
-- CREATE TABLE:
create table employee1(empno int,ename varchar(10),sal
int);
insert into employee1 values(1,'DINESH',1000);
insert into employee1 values(2,'RAMESH',1200);
insert into employee1 values(3,'RAKESH',1500);
select * from employee1;
--UPDATE RECORD OF A TABLE:
update employee1 set sal = sal+500 where empno = 3;
--DELETE A RECORD:
delete from employee1 where empno = 3;