02_mysql模版

2021-03-17  本文已影响0人  渣渣戴

显示数据库:show databases;

新建数据库:create database number1;

切换数据库:use 数据库名;

新建table:CREATE TABLE number001(id INT NOT NULL AUTO_INCREMENT,name VARCHAR(100) NOT NULL,farther VARCHAR(40) NOT NULL,mother VARCHAR(40) NOT NULL,submission_date DATE,PRIMARY KEY ( id ));

新建table:CREATE TABLE number002(id INT NOT NULL AUTO_INCREMENT,name VARCHAR(100) NOT NULL,age int(8) NOT NULL,salary int(12) NOT NULL,submission_date DATE,PRIMARY KEY ( id ));

展示table所有的列:SHOW FULL COLUMNS from number001;

插入语句:insert into number001(id,name,farther,mother) values(1,'tom','tom_farther','tom_mother');

insert into number002(id,name,age,salary) values(1,'tom',28,10000);

查询语句:select * from number001 where id=1;

更改语句:update number001 set name="tom11" where id=3;

删除语句:delete from number001 where id=1 and name=tom;

计数统计:select count(*) from number001 where sex=1;

统计平均数:select avg(salary) from number001;

统计总是:select sum(salary) from number001;

筛选并且显示:select * from number001 group by salary;

查询每一列:select  age ,name,sex from number

刷新:flush privileges;

上一篇下一篇

猜你喜欢

热点阅读