DDL Commands

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy