BCA RDBMS PRACTICAL NUMBER_1

PRACTICAL NUMBER_1 

➤Create tables named employee, department, Salary, Implement all DDL commands on it.

DDL (Data Definition Language) Commands are-
  1. Create,
  2. Alter table (to Add Column, to Modify Column and to DROP Column)
  3. Rename
  4. Truncate
  5. Drop
1. Create table Command-->

SQL> connect ⤶
Enter user-name: system⤶
Enter password : password⤶

connected

SQL>Create table Employee ( Emp_Id int primary key, Name varchar(20) , age int, city varchar(30));⤶
Table Created.

SQL> Create table Department( DeptId int primary key, Dept_Name varchar(20));⤶
Table Created.

SQL> Create table Salary ( Emp_Id int, Salary numeric(10,2));⤶
Table Created.

DDL Commands-Create Table
DDL Commands-Create Table


2. (a) Alter Table Command to Add Column--> we use this command to add Mobile Column in Employee Table.

SQL> Alter table Employee ADD Mobile number(10);⤶
Table altered.

2. (b) Alter table Command to Modify Column--> we use this command to modify Name Column with Not Null Constraint.

SQL> Alter table Employee MODIFY Name varchar(20) not null;⤶
Table altered.

2. (c) Alter table Command to DROP Column--> we use this command to drop or destroy Name Column.

SQL> Alter table Employee DROP COLUMN Name;⤶
Table altered.

DDL Commands-Alter Table
DDL Commands-Alter Table(Add Column, Modify Column or Drop Column)


3. Rename Command--> this command is used to Rename object and here we will rename Employee table name to Employee_Record.

SQL>rename Employee to Employee_Record;⤶
Table renamed.

4. TRUNCATE Command--> this command is used to delete data permanently. 

SQL>TRUNCATE Table Employee_Record;⤶
Table truncated.

5. DROP Command--> this command is used to drop table, view, user, sequence, synonym etc.

SQL>drop table Employee_Record;⤶
Table dropped.  

DDL Commands- Rename, Truncate, Drop
DDL Commands- Rename, Truncate, Drop


No comments:

Post a Comment