After using other databases such as oracle and sybase, when getting started with the mysql database, I usually care about how to know the current database, what tables are in the database, and what table structure is there? How to execute an External SQL file. This article sorts out some mysql Quick Start information based on the SQL data, hoping to help those who want to know other databases and want to transfer them to mysql.
1: display the database
Show databases,
2: currently selected database,
Mysql> select database ();
+ ------------ +
| DATABASE () |
+ ------------ +
| Test |
+ ------------ +
3: Table information contained in the current database:
Mysql> show tables;
+ --------------------- +
| Tables in test |
+ --------------------- +
| Mytable1 |
| Mytable2 |
+ --------------------- +
4. Get the table structure
Mysql> desc mytable1;
+ --------- + ------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ --------- + ------------- + ------ + ----- + --------- + ------- +
| S1 | varchar (20) | YES | NULL |
+ --------- + ------------- + ------ + ----- + --------- + ------- +
5. Execute External SQL scripts
Shell> mysql <input. SQL
Run input. SQL on the current database.
Or
Shell> mysql test <input. SQL
Run input. SQL on the test database.