SQL / MYSQL operator command CMD in creating database, and insert the data form view

SQL / MYSQL databases, forms, create

Make sure you have installed MySQL and have been configured

① into the work area MySQL

Find a method to enter the program and enter the MySQL password:
Here Insert Picture Description
Method Two:
window + r enter cmd into the command prompt

mysql -u root -p

Mysql and enter password, as follows:
Here Insert Picture Description

② Create a database database

Using the CREATE DATABASE statement to create a database database name

Because the system is not limited in mysql case statement,Just to emphasize capital

Therefore, we can use the following as an example to create a name for the company database
The end of the statement with a semicolon

create database company;

Here Insert Picture Description

③ Check Database

Use SHOW DATABASES; statement See All database

show databases;

We can see the company database has been created
Here Insert Picture Description

④ switching database (selection) database

Use USE statement to switch databases
Switching Database (select the database) so that we create a base table, so the switch to the database is critical that we need
Switch to the company database we just created

use company;

Here Insert Picture Description

⑤ create the table

Use CREATA TABLE statement to create a table Contents of the table separated by commas Do not forget to create endPlus end with a semicolon
Below we create a workmates table, a three, the job number (maximum length 10 characters), name (maximum length 10 characters), age ().

create table workmates
(
id varchar(10),
name varchar(10),
age smallint
);

Here Insert Picture Description

⑥ View List of Tables

Use SHOW TABLES; statement to see all of the table form

show tables;

Here Insert Picture Description

⑦ to display the form structure (DESCRIBE statement)

We see workmates describe the use of statements that we just created a property

describe workmates;

Here Insert Picture Description

⑧ insert data in the table

Use INSERT INTO table VALUES (content 1, content 2 ...);
the following set of data we insert a job number: 201901, name: Simon, Age: 22

insert into workmates values('201901','Simon',22);

Here Insert Picture Description

Here Insert Picture Description
Multiple insertion operation can be performed above table

⑨ display data in the table

Wherein the use of the SELECT statement select * from table shows all the data table;

select *from workmates;

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/qq_41767945/article/details/90759486