标签:charset values char int 常用 now() weight select test
1. 显示数据库 show databases;
show databases;
2. 显示当前数据库
select current_database();
3. 创建数据库
create database db_name;
4. 选择某个数据库
use db_name;
5. 显示当前数据库下的表
show tables;
6. 创建表 create table
create table if not exists my_test( id INT UNSIGNED AUTO_INCREMENT, name_people VARCHAR(40) NOT NULL, submission_time DATETIME, PRIMARY KEY(id) )ENGINE=InnoDB DEFAULT CHARSET=utf8;
7. 描述表结构DESC或者DESCRIBE、show columns from
DESC my_test;
SHOW COLUMNS FROM my_test; #显示表结构
8. 插入数据 insert into
INSERT my_test( id, name_people, submission_time ) VALUES (1, ‘Mary‘, NOW());
9 .查询 select
select * from my_test;
select name_people from my_test;
select name_peole from my_test where id=1;
10. 删除一条记录 delete
delete from my_test where id=1;
11. 删除表中的所有记录,但是保存原来的表结构
delete from my_test;
12. 更新表的某一列 update
UPDATE my_test SET name_people = ‘陛下‘ WHERE id=1
13. 更新多列数据,用 ‘,‘ 逗号隔开
UPDATE my_test SET name_people = ‘将军‘, submission_time = NOW() WHERE id=1
#欢迎交流
标签:charset values char int 常用 now() weight select test
原文地址:https://www.cnblogs.com/qi-yuan-008/p/11864227.html