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.