×
If you want to be powerful, Educate yourself better.
--Your friends at LectureNotes
Close

Note for Database Management System - DBMS By Vjay Narain Narain

  • Database Management System - DBMS
  • Note
  • 6 Views
  • Uploaded 3 months ago
Vjay Narain Narain
Vjay Narain Narain
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

DDL COMMANDS CREATE COMMAND: SQL> create table sub (name varchar(8),age number(5),mark1 number(4),mark2 number(4), 2 mark3 number(4)); Table created. DESC COMMAND: SQL> desc sub; Name Null? Type ----------------------------------------- -------- ---------------------------NAME VARCHAR2(8) AGE NUMBER(5) MARK1 NUMBER(4) MARK2 NUMBER(4) MARK3 NUMBER(4) ALTER COMMAND: 1)ADD COMMAND: SQL> alter table sub add(total number(6)); Table altered. SQL> desc sub; Name Null? Type ----------------------------------------- -------- ---------------------------NAME VARCHAR2(8) AGE NUMBER(5) MARK1 NUMBER(4) MARK2 NUMBER(4) MARK3 NUMBER(4) TOTAL NUMBER(6) RENAME COMMAND: SQL> rename sub to subha; Table renamed. SQL> desc subha; Name -------------------------NAME AGE MARK1 MARK2 Null? Type --------------- -------- -----------VARCHAR2(8) NUMBER(5) NUMBER(4)

Text from page-2

2)MODIFY COMMAND: SQL> alter table sub modify(mark3 number(6)); Table altered. SQL> desc sub; Name Null? Type ----------------------------------------- -------- ---------------------------NAME VARCHAR2(8) AGE NUMBER(5) MARK1 NUMBER(4) MARK2 NUMBER(4) MARK3 NUMBER(6) TOTAL NUMBER(4) MARK3 NUMBER(6) TOTAL NUMBER(6) TRUNCATE COMMAND: SQL> truncate table subha; Table truncated. SQL> desc sub; ERROR: ORA-04043: object sub does not exist DROP COMMAND: SQL> drop table subha; Table dropped. SQL> desc subha; ERROR: ORA-04043: object subha does not exist

Text from page-3

DQL COMMANDS SQL> create table sub (name varchar(8),age number(5),mark1 number(4),mark2 number(4), 2 mark3 number(4)); Table created. SQL> insert into sub values('&name','&age','&mark1','&mark2','&mark3'); Enter value for name: sachin Enter value for age: 12 Enter value for mark1: 90 Enter value for mark2: 90 Enter value for mark3: 90 old 1: insert into sub values('&name','&age','&mark1','&mark2','&mark3') new 1: insert into sub values('sachin','12','90','90','90') 1 row created. SQL> / Enter value for name: sachin Enter value for age: 22 Enter value for mark1: 90 Enter value for mark2: 89 Enter value for mark3: 78 old 1: insert into sub values('&name','&age','&mark1','&mark2','&mark3') new 1: insert into sub values('sachin','22','90','89','78') 1 row created. SQL> / Enter value for name: ranjan Enter value for age: 21 Enter value for mark1: 89 Enter value for mark2: 78 Enter value for mark3: 80 old 1: insert into sub values('&name','&age','&mark1','&mark2','&mark3') new 1: insert into sub values('ranjan','21','89','78','80') 1 row created.

Text from page-4

SQL> / Enter value for name: gayathri Enter value for age: 12 Enter value for mark1: 78 Enter value for mark2: 89 Enter value for mark3: 90 old 1: insert into sub values('&name','&age','&mark1','&mark2','&mark3') new 1: insert into sub values('gayathri','12','78','89','90') 1 row created. SQL> / Enter value for name: rajini Enter value for age: 22 Enter value for mark1: 90 Enter value for mark2: 87 Enter value for mark3: 56 old 1: insert into sub values('&name','&age','&mark1','&mark2','&mark3') new 1: insert into sub values('rajini','22','90','87','56') 1 row created. SELECT COMMAND: TYPE 1: SQL> select * from sub; NAME AGE MARK1 MARK2 MARK3 -------- ---------- ---------- ---------- ----------------------------sachin 12 90 90 90 sachin 22 90 89 78 ranjan 21 89 78 80 gayathri 12 78 89 90 rajini 22 90 87 56 TYPE 2: SQL> select name,age from sub; NAME AGE -------- ---------sachin 12 sachin 22 ranjan 21 gayathri 12 rajini 22

Lecture Notes