[24] SQL CREATE TABLE Statement

Source: Internet
Author: User

[24] SQL CREATE TABLE Statement

The CREATE TABLE statement is used for creating tables in the database.

Tables consist of rows and columns, and each table must have a table name.

SQL CREATE TABLE Syntax
CREATE TABLE table_name (column_name1 data_type (size), column_name2 data_type (size), Column_name3 data_type (size),....);

The column_name parameter specifies the name of the column in the table.

The Data_type parameter specifies the data type of the column (for example, varchar, integer, decimal, date, and so on).

The size parameter specifies the maximum length of the column in the table.

SQL CREATE TABLE Instance

Now we want to create a table called "Persons" that contains five columns: PersonID, LastName, FirstName, Address, and city.

We use the following CREATE TABLE statement:

Instance
CREATE TABLE  the intvarchar(255varchar(255  varchar (255varchar(255));

The data type of the PersonID column is int, which contains integers.

The data types of the LastName, FirstName, Address, and city columns are varchar and contain characters, and the maximum length of these fields is 255 characters.

The empty "Persons" table looks like this:

[24] SQL CREATE TABLE Statement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.