0% found this document useful (0 votes)
18 views2 pages

Print K Liye

The document describes SQL commands used to create, alter, and drop database tables. It creates an Employee_details table with fields like EmpID, EmpName etc. and alters the table by adding/modifying fields. It then creates a Product table and alters it before dropping the Product table. In the end it shows the list of tables which now only contains the Employee_data table.

Uploaded by

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

Print K Liye

The document describes SQL commands used to create, alter, and drop database tables. It creates an Employee_details table with fields like EmpID, EmpName etc. and alters the table by adding/modifying fields. It then creates a Product table and alters it before dropping the Product table. In the end it shows the list of tables which now only contains the Employee_data table.

Uploaded by

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

CREATE TABLE Employee_details (EmpID INT PRIMARY KEY,EmpName VARCHAR(255) NOT

NULL,Designation
VARCHAR(255),Emp_dept VARCHAR(255),Salary int,EmpDOB DATE,EmpAge INT);
desc Employee_details;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| EmpID | int | NO | PRI | NULL | |
| EmpName | varchar(255) | NO | | NULL | |
| Designation | varchar(255) | YES | | NULL | |
| Emp_dept | varchar(255) | YES | | NULL | |
| Salary | int | YES | | NULL | |
| EmpDOB | date | YES | | NULL | |
| EmpAge | int | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+

alter table Employee_details add contact int;


+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| EmpID | int | NO | PRI | NULL | |
| EmpName | varchar(255) | NO | | NULL | |
| Designation | varchar(255) | YES | | NULL | |
| Emp_dept | varchar(255) | YES | | NULL | |
| Salary | int | YES | | NULL | |
| EmpDOB | date | YES | | NULL | |
| EmpAge | int | YES | | NULL | |
| contact | int | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+

alter table Employee_details modify Designation varchar(200);


+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| EmpID | int | NO | PRI | NULL | |
| EmpName | varchar(255) | NO | | NULL | |
| Designation | varchar(200) | YES | | NULL | |
| Emp_dept | varchar(255) | YES | | NULL | |
| Salary | int | YES | | NULL | |
| EmpDOB | date | YES | | NULL | |
| EmpAge | int | YES | | NULL | |
| contact | int | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
alter table Employee_data drop empage;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| EmpID | int | NO | PRI | NULL | |
| EmpName | varchar(255) | NO | | NULL | |
| Designation | varchar(200) | YES | | NULL | |
| Emp_dept | varchar(255) | YES | | NULL | |
| Salary | int | YES | | NULL | |
| EmpDOB | date | YES | | NULL | |
| contact | int | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+

CREATE TABLE Product (prod_no INT PRIMARY KEY,prod_name VARCHAR(255)


NOT NULL,quantity INT,sell_price int);
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| prod_no | int | NO | PRI | NULL | |
| prod_name | varchar(255) | NO | | NULL | |
| quantity | int | YES | | NULL | |
| sell_price | int | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+

alter table Product add Product_Brand int;


+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| prod_no | int | NO | PRI | NULL | |
| prod_name | varchar(255) | NO | | NULL | |
| quantity | int | YES | | NULL | |
| sell_price | int | YES | | NULL | |
| Product_Brand | int | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+

drop table product;


show tables;
+--------------------+
| Tables_in_nikita67 |
+--------------------+
| employee_data |
+--------------------+

You might also like