How to use the terminal to operate the database
How to log database
mysql -u用户名 -p密码
such as:
mysql -uroot -p123456
How to query the database server for all databases
show databases;
How to select a certain database operations
use 你要操作的数据库;
such as
use sys;
sql statement query
select * from 你要查询的选中数据库里的内容
Tip: If the selected database is not what you want to query are displayed
Table 'sys.sys' doesn't exist
Query by the conditions such as querying data id = 1
select *from admin where Admin_ID=1;
How to exit the database server
exit;
How to create our server in the database server
create database test;
(Creates a database named test)
How to view the selected data tables inside the database
show tables;
How to create a data table
Create a pet such as a data table
create table pet ( name varchar(20), owner varchar(20), species varchar(20), sex char(1), birth DATE, death DATE);
Check the created data table details
describe pet;
How to view the recorded data in the table?
select * from pet;
How to add data record to the data table?
insert into pet
values('puffball','diane','hamseter','f','1999-03-30',NULL);
mysql common data types
Numerical
Date / Time
String type
How to choose the type of data
Select the date in the format
Values according to the size and the string
How to remove data
delete from pet where name='wangcai';
How to modify the data
update pet set owner='bababa' where name='wangcai';
to sum up
Increase insert
Delete delete
Modify update
Query select