Preliminary study MySQL

Before we learn how to install MySQL database management database and visualization tool navicat

So now primarily to learn about how to use (there are many ways to operate the database, terminal operation, visualization tools operation, programming operation statement)

We first study the operation of the terminal database (windows + r cmd)

Log database server : mysql -u root -p password or Enter the mysql -u root -p and then enter the password

Exit the database server : exit

How to query the database for all database servers : show databases; (semicolon must take the state under the semicolon in English)

How to select a database operation : use the database name, such as: use test

----------------------------------------------------------------

How to create a database server database : create database database name; (create database test1;)

View all the tables in a database : show tables;

How to create a data table : create table user (name varchar ( 20), owner varchar (20), species varchar (20), sex char (1), birth date, death date);

          The above is an example, create table name of the table (the type of key data, key data type (NUM), ......);

How to view a table of specific structure : describe table name; (describe user);

+---------+-------------+------+-----+---------+-------+
| Field   | Type              | Null   | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name    | varchar(20) | YES  |        | NULL    |         |
| owner   | varchar(20) | YES  |        | NULL    |         |
| species | varchar(20) | YES  |        | NULL    |         |
| sex       | char(1)        | YES  |         | NULL    |        |
| birth     | date             | YES  |         | NULL    |        |
| death   | date             | YES  |         | NULL    |        |
+---------+-------------+------+-----+---------+-------+

field: Field Name; type: field type; null: Can be empty; key: constraint type, default: the default value; extra: additional information;

 

Guess you like

Origin www.cnblogs.com/fqh123/p/11619754.html