MySQL basic command
SQL features
DML(数据操作语言):用于检索或修改数据。DDL(数据定义语言):用于定义数据的结构,如创建、修改或者删除数据库对象。DCL(数据控制语言):用于定义数据库用户的权限。
View Database
show databases;
Working with databases
use test1;
View tables in the database
show tables;
View table Structure
desc people;
Database creation Scripts
create table people(id INT AUTO_INCREMENT PRIMARY KEY,name VARCHAR(30) NOT NULL,password VARCHAR(30) NOT NULL,age INT NOT NULL,sex VARCHAR(2) DEFAULT‘男‘,birthday date);
Add data
insert into people (name,password,age,sex,birthday) values (‘zhangsan‘,‘1997‘,21,‘男‘,‘2005-02-02‘);
Delete data
delete from people where name=‘zhangsan‘;
Querying data
select * from people;select age from people where name=‘zhangsan‘;
modifying data
update people set age=36 where name=‘zhangsan‘;
Reference Tutorials
After the basic operation, there will be many problems in the actual operation.
- When a table is built, the last line does not need a comma (,), which is why I have been bothering for a long time.
- Inserting Chinese characters is not allowed when inserting data, because the database does not have coding reasons. Reference URL
- Input always avoid unavoidable input errors, but sometimes input exit or quit and so on, the way is that some of the commands are in pairs appear, input error when the other half to fill on it. Reference URL
- The cmd window is not easy to use with a panel window, but the command line can be greatly improved. After entering the command line, if you prompt the error, look at the error prompt, it is generally a good solution. You can see the picture below for details.
MySQL basic command