一. 数据表的操作
1. 创建表结构
create table 表名(
age int,
name varchar(11)
);
create table 表明(
age int,
name varchar(11)
)character set utf8 collate utf8_bin;
2. 删除表
drop table 表明;
3. 更改表
rename table 表名 to 新表名;
alter table 表名 character set utf8;
4. 查
show tables;
desc 表名;
show create table 表名;
二. 表中字段的操作
1. 增
alter table 表名 add 新字段名 数据类型;
2. 删
alter table 表名 drop 字段名;
3. 改
alter table 表名 change 旧字段 新字段 数据类型;
4. 查
desc 表名;
三. 表中数据的操作
1. 增
insert into 表名
set 列号 = 列值,
列号 = 列名;
insert inot 表名(列名,可以默认)
values(值,一一对应)
2. 删
delete from 表名;
delete from 表名 where name = "名,名";
truncate 表名;
3. 改
update 表名
set name = "数据" where id = 1;
4. 查
select * from 表名;
select id as yu from 表名;