Home > Database > Mysql Tutorial > body text

How to create a database table

青灯夜游
Release: 2023-01-05 16:13:52
Original
67246 people have browsed it

In the database, you can use the "CREATE TABLE" statement to create a table. The syntax format is "CREATE TABLE table name (column name 1 data type (maximum length) 1 [,...] column name n data type ( Maximum length)n);".

How to create a database table

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

Creation of tables in database

The process of creating a data table is the process of specifying the attributes of the data columns, and it is also the process of implementing data integrity (including entity integrity, reference integrity and domain integrity) constraints.

Basic syntax

In MySQL, you can use the CREATE TABLE statement to create a table. The syntax format is:

CREATE TABLE <表名> ([表定义选项]);
Copy after login

Among them, the format of [table definition option] is:

<列名1> <数据类型(size)1> [,…] <列名n> <数据类型(size)n>
Copy after login

The main syntax and usage instructions of the CREATE TABLE statement are as follows:

CREATE TABLE: For creating a table with a given name, you must have table CREATE permissions.