0% found this document useful (0 votes)
63 views3 pages

Abhisek 3

The document outlines the use of Data Definition Language (DDL) commands in RDBMS, including creating, altering, renaming, truncating, and dropping tables. It provides examples of SQL queries for each command, demonstrating how to manage database structures effectively. The document also includes specific commands for modifying table columns and structures, showcasing practical applications of DDL in database management.

Uploaded by

Aman Baghel
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)
63 views3 pages

Abhisek 3

The document outlines the use of Data Definition Language (DDL) commands in RDBMS, including creating, altering, renaming, truncating, and dropping tables. It provides examples of SQL queries for each command, demonstrating how to manage database structures effectively. The document also includes specific commands for modifying table columns and structures, showcasing practical applications of DDL in database management.

Uploaded by

Aman Baghel
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/ 3

Enrollment no – 0103IT201011

Experiment- 3
Aim: To write a query with a function of data definition language (DDL)
commands such as create, alter, rename, truncate in RDBMS.
1. About DDL statements:
A data definition language (DDL) is a computer language used to create and modify the
structure of database objects in a database. These database objects include views,
schemas, tables, indexes, etc. This term is also known as data description language in
some contexts, as it describes the fields and records in a database table.
2. How to create table in Database .
mysql> create table Stud_INFO(Stud_name varchar(10), Stud_ID int(4),Stud_address
varchar(10));
Query OK, 0 rows affected, 2 warnings (2.30 sec)
3. How to show the structure or description of the table.
mysql> desc student_INFO;
+----------------+----------------+------- +-------+--------- +------ +
| Field | Type | Null | Key | Default | Extra |
+----------------+----------------+-------+--------+---------+-------+
| Stud_name | varchar(10) | YES | | NULL | |
| Stud_ID | int (4) | YES | | NULL | |
| Stud_address | varchar(10) | YES | | NULL | |

4. How to alter previous created column data type and length.


mysql>alter table Stud_INFO modify Stud_ID varchar(10);
Query OK, 0 rows affected (2.81 sec)
Records: 0 Duplicates: 0 Warnings: 0
5. How to check changes is made in table.
mysql> desc Stud_INFO;
+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default |Extra |
+----------------+---------------+------+-----+---------+-------+
| Stud_name | varchar(10) | YES | | NULL | |
| Stud_ID | varchar(10) | YES | | NULL | |
| Stud_address | varchar(10) | YES | | NULL | |

6. How to change the name of the column in table.


mysql> alter table Stud_INFO change Stud_ID Stud_Enrollment int(10);
Query OK, 0 rows affected, 1 warning (1.50 sec)
Records: 0 Duplicates: 0 Warnings: 1
mysql> desc Stud_INFO;
+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |

Name: Abhishek Prajapati Roll no. 11


Enrollment no – 0103IT201011

+--------------------+----------------+------+-----+---------+-------+
| Stud_name | varchar(10) | YES | | NULL | |
| Stud_Enrollment | int | YES | | NULL | |
| Stud_address | varchar(10) | YES | | NULL | |

7. How to add new column in the table.


mysql> alter table Stud_INFO add stud_phno int(10);
Query OK, 0 rows affected, 1 warning (1.41 sec)
Records: 0 Duplicates: 0 Warnings: 1

mysql> desc Stud_INFO;


+--------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+-------+
| Stud_name | varchar(10) | YES | | NULL | |
| Stud_Enrollment | int | YES | | NULL | |
| Stud_address | varchar(10) | YES | | NULL | |
| stud_phno | int | YES | | NULL | |

8. How to drop column from table.


mysql> alter table Stud_INFO drop stud_phno;
Query OK, 0 rows affected (1.60 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc Stud_INFO;
+--------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+-------+
| Stud_name | varchar(10) | YES | | NULL | |
| Stud_Enrollment | int | YES | | NULL | |
| Stud_address | varchar(10) | YES | | NULL | |

9. How to change the name of table .


mysql> rename table Stud_INFO to student_info;
Query OK, 0 rows affected (0.59 sec)
mysql> show tables;
+-----------------------------------+
| Tables_in_student_admission|
+-----------------------------------+
| department_data |
| employee_info |
| student_info |

10. How to truncate data in table.

Name: Abhishek Prajapati Roll no. 11


Enrollment no – 0103IT201011

mysql> truncate table table_name;


Empty set (0.00 sec)

11. How to drop the table.


mysql> drop table table_name;
Query OK, 0 rows affected ( 0.01 sec)

Name: Abhishek Prajapati Roll no. 11

You might also like