show databases
select database()
show tables
desc tablename;
CREATE DATABASE blog DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE DATABASE blog DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
create table students id int not null auto_increment primary key,name varchar(30));
>
<
>=
<=
!=
=
select * from product where pid < 3;
select pname from product where pid < 3;
or
and
not
select * from product where pid<3 and is_hot=1;
like
%
_
select * from product where pname like "小%";
select * from product where pname like "%兴%";
select * from product where pname like "小_";
in
between...and
select * from product where market_price in (649, 1399)
select * from product where market_price between 1000 and 2000;
null != ""
is null
is not null
select * from product where punit is null;
select count(*) from product;
select max(market_price) from product;
select sum(market_price) from product;
select avg(market_price) from product;
select * from wyt2 where date(t1) = '2019-10-18';
mysql> select sex as 性别, count(*) from user group by sex;
+--------+----------+
| 性别 | count(*) |
+--------+----------+
| NULL | 6 |
| 男 | 5 |
+--------+----------+
select sex as 性别, count(*) from user group by sex having sex="男";
+--------+----------+
| 性别 | count(*) |
+--------+----------+
| 男 | 5 |
+--------+----------+
mysql> select sex as 性别,count(*) from user where sex = "男";
+--------+----------+
| 性别 | count(*) |
+--------+----------+
| 男 | 5 |
+--------+----------+
select * from product where is_hot=1 order by market_price ;
select * from students
where isdelete=0
limit (n-1)*m,m
insert into students (sname) values ("Gage");
update students set sname="Fovegage" where id = 1;
delete from students where id =1;
ALTER TABLE attence MODIFY COLUMN id INT(20)
ALTER TABLE attence ADD COLUMN age VARCHAR(20) NOT NULL;
ALTER TABLE attence CHANGE attence_name NAME VARCHAR(20)
ALTER TABLE attence DROP COLUMN age;
DROP table tablename;
delete from tablename;
# 会在二进制中记录truncate table tablename;
# 直接删除,不会在二进制中记录drop database databasename;