Create a complete table in the MySQL database, and create a mysql database
1. After successful login, first enter a database (not a database server)
Use t1; // t1 is the database name
:
2. Create a database table in this database
2.1 first create a table structure (which can be understood as the column name of the table, that is, the field name). In actual production, the table structure needs to be carefully designed.
The common syntax format is:
1 CREATE TABLE table_name (column_name column_type);
Example:
1 create table tb3(2 id smallint unsigned auto_increment primary key,3 username varchar(20) not null4 );
2.2 view the created table structure
Syntax format:
1 show columns from [Table name];
Example: show colums from Fig;
The table structure in Table t3 contains two fields: id and username;
The values of both fields cannot be blank, and the id field is the primary key.
3. insert and search records
The table records in the Database correspond to the rows in the table.
3.1 insert record
Syntax format of insert record:
Inset {table name} (filed1, field2,...) values (value1, value2 ,....);
Example:
1 insert tb3 (id,username) values (4,'jona');
3.2 query records
Syntax format:
1 select {filed1, filed2,...} from {table name };
Example:
Select id, username from Fig;