MySQL Data sheet basic operations

Source: Internet
Author: User

First, create a data table

Syntax:CREATE TABLE table name (Field field type [Field Properties], Field field type [Field Properties],...) [Table options];

Table options: Data table properties, typically including engine, CharSet, collate

Engine: Storage engine, the way MySQL provides specific storage data, by default is InnoDB (before the 5.5 version is MyISAM)

CharSet: Character set, valid only for current data table (level is higher than database)

Collate: Proofing Set

Extension: Create a data table by copying an existing table structure, copy only the structure, and the data in the table is not copied

Syntax:CREATE table A new table name like already has a list name;

PS: The existing table name can be the current database, or it can come from another database (accessed through the "Database name. Table Name" method)

Second, view the data sheet

2.1 View All data sheets

Syntax:show tables;

2.2 Viewing some data sheets

Syntax:show tables like "match pattern";

2.3 Viewing the data table structure

Syntax:desc table name, or Show columns from table name;

Third, modify the data table

3.1 Modifying table names

Syntax: Rename table name tonew table name;

3.2 Modifying data table options

Syntax:ALTER TABLE table name new tables option;

Note: If data is already in the table, modify the table options carefully!

3.3 Modifying the data table structure

New field syntax:ALTER TABLE name add field Name field type [fields Properties] [position];

PS: If you do not specify a location, the default is placed after the last field

Modify field syntax: ALTER TABLE name change old field name new field name new fieldType [New field property] [new position];

Note: If you just want to modify the field name simply, you can only modify the field name, the field type can be used originally, but not empty!

Modify field type and attribute syntax:ALTER TABLE table name modify field name new field type [new Field property] [new location];

Delete field syntax:ALTER TABLE name drop field name;

Iv. Deleting Data sheets

Syntax:drop table name;

MySQL Data sheet basic operations

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.