Create a complete table in the MySQL database

Source: Internet
Author: User

1. After successful landing, first enter a database (not the database server)

T1;  T1 is the database name

2. Create a database table in this database

2.1 First establish the table structure (can be understood as the table column name, that is, the field name) in the actual production process, the table structure needs to be carefully designed.

The common syntax format is:

1 CREATE TABLE table_name (column_name column_type);

Examples are as follows:

1 Create Table tb3 (2    smallint Primary Key , 3    varchar (notnull4    );

2.2 Viewing the established table structure

The syntax format is:

1  from [ table name ];

Example: Show colums from TB3;

You can see that the table structure in table T3 contains two fields: Id,username;

Two field values are not allowed to be NULL, the ID field is the primary key.

3. Insertion and lookup of records

The table records in the database correspond to the rows in the table.

3.1 Insertion of records

The inserted syntax format for the record:

Values (Value1,value2,....);

Examples are as follows:

1 Insert Values (4,'jona');

3.2 Querying Records

Syntax format:

1 Select  from {table name};

Examples are as follows:

Select Id,username from Tb3;

Create a complete table in the MySQL database

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.