标签:int 创建 name 它的 engine 创建表 修改 innodb 允许
mysql介绍:
它是数据库,存储数据用的,增、删、改、查是对其使用的最基本的要求。
一、mysl
基本操作:
1.库操作
create database q1; 创建一个q2数据库;
drop database q1; 删除q1数据库;
show databases; 展示所有数据库;
2.表格操作
创建表格:
create table 表名(
列名 类型 是否可以为空, 列名 类型 是否可以为空 )ENGINE=InnoDB DEFAULT CHARSET=utf8删除表格:
drop table 表名;
清空表格;
delete from 表名;
truncate table 表名;
修改表格:
增加列 alter table 表名 add coob int
删除列 alter table 表名 drop column 列名
修类型:
修改类型 alter table 表名 modify column 列名 类型; 修改名称与类型 alter table 表名 change 原列名 新列名 类型;添加主键:alter table 表名 add primary key(列名);
删除主键:alter table 表名 drop primary key;
alter table 表名 modify 列名 int, drop primary key;
3.列操作
增:
单条添加 insert into t1(coob,mary) values(1,"girl")
多条添加 insert into 表 (列名,列名...) values (值,值,值...),(值,值,值...)
删:
delete from 表 where coob=1 and mary=‘alex‘
清空表 delete from 表
改:update 表 set mary = ‘alex‘ where coob>1 更改mary列的所有值为alex 前提是(coob的值小于1)
查:
select * from 表 显示所有的列及内容
select * from 表 where id > 1 显示id值大于1的所有内容。 select nid,name,gender as gg from 表 where id > 1
二、pymysql
标签:int 创建 name 它的 engine 创建表 修改 innodb 允许
原文地址:http://www.cnblogs.com/learn-python-M/p/7072874.html