11.表和库的管理
一.创建数据表
create table t_student
(
id int primary key auto_increment,
name varchar(10) not null,
age int,
sex varchar(8) not null default '女',
address varchar(100),
height double,
birthday date
)charset=utf8;
二.添加数据
insert into t_student (name,age,sex,birthday,height)
values ('范婷婷',18,'女','1998-12-4',170.6);
insert into t_student(name,age,sex)
values(null,10,'男');
insert into t_student
values(null,'程瑞',19,'男','南京',176.6,now())
三.修改数据表
1.添加列
alter table t_student add weight double;
2.修改列类型
alter table t_student modify name varchar(250);
3.修改列名
alter table t_student change sex gender varchar(8);
4.修改表名
alter table t_student rename student;
rename table student to t_student;
四.删除表
drop table if exists user;
五.截断表
truncate table emp;
六.创建库
create database if not exists shop charset utf8;
七.删除库
drop database if exists shop;