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:
Method Two:
window + r enter cmd into the command prompt
mysql -u root -p
Mysql and enter password, as follows:
② 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;
③ Check Database
Use SHOW DATABASES; statement See All database
show databases;
We can see the company database has been created
④ 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;
⑤ 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
);
⑥ View List of Tables
Use SHOW TABLES; statement to see all of the table form
show tables;
⑦ to display the form structure (DESCRIBE statement)
We see workmates describe the use of statements that we just created a property
describe workmates;
⑧ 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);
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;