从table1提取一个数据插入到table2中
select name,age
into table2 from table1 where age between 20 and 30
创建数据语句
create databse my_sql.db
创建表的sql
create table student (name var,age int,score int)
constraints
constraints 字段名 foreign key references person(ip_d)
foreign key (ip_d) references person(id_p)
添加外建约束
alter table order add foreign key(id_p) references person(id_p)
撤销外建约束
alter table order drop foreign key 字段名
check
alter table person add check (id_p>0)
检查约束命名约束
alter table person constranits person_pk check (id_p>0)
撤销检查约束
alter table person drop check person_pk
默认约束
alter table person add constraints person_sk default ('地址不详') for city
撤销默认约束
alter table person alter city drop default
创建索引
create index 索引名 on table(表字段名)
创建唯一索引
create unique index 索引名 on table(表字段名)
降序索引
create index 索引名 on table(表字段名 desc)
撤销索引
alter table 表名 drop index 索引名
删除表内容
truncate table 表名