Commands of DBMS SQL

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

oracle username password: scott/tiger@orcl

* Tables name 1) stud_0020


2) program_0020

* Copy tables name 1) stud_cpy_0020


2) program_cpy_0020

===> select * from table ; {to show the table present on the server at given time}
===> drop table [table name] ; {to drop any existing table}

===> create table [table name] ;


(stud_no char(4),
stud_name varchar(10),
stud_add varchar(10),
stud_phone number(10),
fees_paid number(8,2),
stud_DOB date);
===> describe [table name] {to view table}

===> create table [table name] ;


(prog_id char(4),
prog_name varchar(10),
hod_name varchar(10) ) ;
===> describe [table name] {to view table}

===> alter table [table name] ;


add column [column name] [datatype (size)] ;
===> describe [tablename] {to view table}

===> select * from [table name] ; {to add data to existing table created}
insert into program_0020 values ('P001','BSC-IT','Prashant');
insert into stud_0020 values ('P001','BSC-IT','Prashant');
insert into [table name] values ('P001','BSC-IT','Prashant');
insert into [table name] values ('P001','BSC-IT','Prashant');

===> update program_0020 set prog_id = 'P002' where prog_name = 'BMM' ; {to change
the value inside the table}

===> create table stud_cpy_0020 as select * from stud_0020 {to create a copy table
from existing table}

===> alter table stud_0020 modify fees_paid number(10,2); {to alter any table
feild}

===> alter table stud_cpy_0020 drop column stud_add; {to drop any particular
existing feild from table}

===> drop table program_cpy_0020; {drop/delete the whole table, but structure
remains}

===> truncate table stud_cpy_0020; {delete the row/data from the table , still
structure remains}

===> rename program_0020 to program_cpy_0020; {rename the table name}

You might also like