1. Create a table
Basic syntax
Create Table tableName ( field1 datatype, field2 datatype, field3 datatype );
View CodeField: Queue name datatype: column type
Create a student table example:
Create Table Student ( int, varchar() Char (6));
View Code
2. Modify the table
2.1 Adding columns to a table
Basic syntax
Alter Table tableName Add (column datatype);
Add Student table One column sorce, type int
Alter Table Student Add int);
View Code
2.2 Modifying a table's columns
Basic syntax
Alter Table tableName Modify (column datatype);//commonly used to modify data types
Change the name length of the student table to 60
Alter Table Student varchar ());
View Code
2.3 Deleting a table's columns
Basic syntax
Alter Table tableName Drop (column);
Delete Student's Sorce
Alter Table Student drop Sorce;
View Code
3. Other syntax
Modify the name of the table:
to Newtablename;
To modify the character set of a table:
Alter Table character set UTF8;
MySQL basic syntax-the operation of the table