mysql -uroot -pmysqlpython
quit, exit, ctrl+Dmysql
select now();sql
show databases;數據庫
create datsbase python1 charse=utf8;ui
use python1排序
select database();rem
drop database python1;字符串
show tables;it
create table students(id int unsigned primary key auto_increment not null, name varchar(30) notnull, age tinyint not null default 0);table
desc students;
alter table students add birthday datetime default 0;
alter table students modify birthday date not null;
alter table students change birthday birth date not null;
alter table students drop birthday;
select create table students;
select create database python1;
drop table students;
drop database pytohn1;
insert into students values(0, '張三', 18);
insert into students(name) values('張三')
update students set name = '李四';
update students set name = '李四' where id = 1;
delect from students where id = 2;
alter table students add id_delect bit default 0;
update studets det students.id_delect = 1 where id = 2;
select * from students where id_delect = 1;
select * from students;
select id, birth from students;
select * from students order by age desc;
(給字段起別名) select id as i, birth as b from students;
(給表起別名) select s.id, s.birth from student as s;
select distinct id from students;
(比較) select * from students where age > 7;
(邏輯) select * from students where age > 5 and age < 7;
(模糊) select * from students where name like '黃%_' ----(%替換任意個, _替換一個)
(範圍) select * from students where age in (1, 2, 3, 5) ----(不連續範圍)
(空) select * from students where age is not null;
select * from students where age between 2 and 7;