python 笔记 之 表操作 DML语句

'''
表操作 DML语句
'''

'''
查
select 列名 from 表名 where 条件判断
select * from sutdent where id > 1000
select * from test group by name having count(*)>1;
select * from test group by name having count(*)>1 order by name; # 排序
select * from test group by name having count(*)>1 order by id desc; # 反序

多表查询
select * from a,b, where a.id = c.组id 
select a.id,a.name,b.id from a join c on c.组id = a.id  and ...

'''

'''
曾
insert into table_name (id,name,age ) values (i,'aa',22)
删
delete from table_name where 条件
改
update table_name set 列名=xx where 条件

truncate  # 只清除数据,不删表结构
drop #删表结构
desc table_name ;
show create  table;
#查10行
select * from table_name limite 10;

'''

'''
#建索引
create index 库名_表名_列名1_列名2(列名1,列名2)
show index from test;
#创建索引
alter table test add index
#查看是否有索引,有索引就快
explain select * from test where name="aaa";

'''

'''
ORM思想
'''

猜你喜欢

转载自my.oschina.net/u/3824134/blog/1809212