[Daily update-mysql Basics] 3. Data Sheet wipe Oh, go.

Source: Internet
Author: User

1. Data sheet operation

The data table is the most important thing to store the data, it exists in the library, there can be more than n tables in a library. Therefore, you must select a library to create a data table.


1.1 Creating a data table


CREATE TABLE <tableName> (
Information for the table
) [Options];

It is not possible to create a table without specifying the data, and there are two ways to select the library.

1. Specify when writing the table name: CREATE table library name. Table Name

2. Before you create a table, use: The name of the using library; Switch to the specified database and then do the operation

Attention:

When creating a table, the If not EXISTS syntax is also supported

Options include:

Engine: Engines (currently popular are: MyIsam and InnoDB)

CharSet: Character Set

After creating the data table, we can find the corresponding table file in the database folder.

If you create a data table that is a MyISAM engine, three files are created:. frm files are table structures. myd files are data,. myi files are indexes

If you create a data table that is the InnoDB engine , the created file will be different.

1.2 See which tables are in the library

Show tables [Like <name>];

Similar to the usage of show databases

1.3 Viewing statements that create tables

Show CREATE TABLE <tablename>;1.3
1.4 View Table Structure

Desc <tableName>;
1.5 Deleting a table

drop table [if exists] <tableName>;
1.6 Modifying a table

ALTER TABLE <tableName> options = new value;

Re-modify the name of the table:

Rename table name to new table name:
1.7 Modification of the field

To add a field:

ALTER TABLE <tableName> Add column fields define the position;

To delete a field:

ALTER TABLE <tableName> drop column field name;

field modification definition and renaming at the same time

ALTER TABLE <tableName> change column Old field name new field definition (name, field) position;

The field only modifies the definition:

ALTER TABLE <tableName> modify column field name new defined position;


[Daily update-mysql Basics] 3. Data Sheet wipe Oh, go.

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.