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