Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

One minute to get to know mysql DDL.

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Xiaobian to share with you a minute to take you to understand mysql DDL, I hope you have something to gain after reading this article, let's discuss it together!

SQL classification:

SQL statements can be divided into three main categories:

DDL statements: Data definition language, these statements define different data segments, databases, tables, columns, indexes and other database objects. Common sentence keywords mainly include create, drop, alter, etc.

DML statements: Data manipulation statements used to add, delete, update, and query database records and check data integrity. Common sentence keywords include insert, delete, update, select, etc.

DCL statement: Data control statement, used to control the direct permission and access level of different data segments. These statements define databases, tables, fields, user access rights, and security levels. The main sentence keywords include grant, revoke, etc.

We'll focus on DDL statements today.

1. create a database

Grammar:

create database name;

Select the database to operate: USE database; for the database to operate we need to use to select!

View all data tables in the database show tables;

mysql> create database test;//Create database Query OK, 1 row affected (0.00 sec)mysql> use test;//Use newly created database Database changedmysql> show table;Empty set (0.11 sec)//View table in database, because we did not create, so empty

2. Delete database:

Grammar:

drop database name;

Examples:

mysql> drop database test;//delete the database we just created

3. Create a table (in which database to create a table need to use to select the database to operate)

Grammar:

create table table name (constraints of field 1 name field 1 type column, constraints of field 2 name field 2 type column,...);

Examples:

mysql> create table student//Create data table ->( ->ID Int, ->Name varchar(12) ); Query OK, 0 row affected (0.13 sec)

4. delete table

Grammar:

drop table name;

Examples:

mysql> drop table student;//delete the data table we just created After reading this article, I believe you have a certain understanding of "one minute to take you to understand mysql DDL", if you want to know more related knowledge, welcome to pay attention to the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report