0% found this document useful (0 votes)
12 views

DDL Commands

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

DDL Commands

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

1.

DDL Commands
mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| cdcol |

| db1 |

| mysql |

| phpmyadmin |

| test |

+--------------------+

6 rows in set (0.31 sec)

mysql> create database db01;

Query OK, 1 row affected (0.00 sec)

mysql> use db01;

Database changed

mysql> create table std_det(name varchar(10), age int(3), reg_no varchar(10));

Query OK, 0 rows affected (0.14 sec)

mysql> desc std_det;

+--------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+-------------+------+-----+---------+-------+

| name | varchar(10) | YES | | NULL | |


| age | int(3) | YES | | NULL | |

| reg_no | varchar(10) | YES | | NULL | |

+--------+-------------+------+-----+---------+-------+

3 rows in set (0.11 sec)

mysql> alter table std_det add(address varchar(10));

Query OK, 0 rows affected (0.12 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> rename table std_det to stud_detail;

Query OK, 0 rows affected (0.00 sec)

mysql> desc stud_detail;

+---------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------+-------------+------+-----+---------+-------+

| name | varchar(10) | YES | | NULL | |

| age | int(3) | YES | | NULL | |

| reg_no | varchar(10) | YES | | NULL | |

| address | varchar(10) | YES | | NULL | |

+---------+-------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> truncate table stud_detail;

Query OK, 0 rows affected (0.00 sec)

mysql> desc stud_detail;


+---------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------+-------------+------+-----+---------+-------+

| name | varchar(10) | YES | | NULL | |

| age | int(3) | YES | | NULL | |

| reg_no | varchar(10) | YES | | NULL | |

| address | varchar(10) | YES | | NULL | |

+---------+-------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> drop table stud_detail;

Query OK, 0 rows affected (0.01 sec)

You might also like