表的基本操作
来源:互联网 发布:人工智能的弊端论文 编辑:程序博客网 时间:2024/05/18 01:41
--班级信息表create table tab_class( id number(3), name varchar2(10)); --学生信息表create table student( id number(3),class_id number(3), name varchar2(10), sex char(1),age number(3),note varchar2(100) );--重命名表alter table tab_class rename to tab_class2;--修改列名 alter table tab_class2 rename column name to name2; --添加主键约束 alter table tab_class2 add constraint pk_id primary key(id); --添加外键约束alter table student add constraint fk_class_id foreign key(class_id) references tab_class2(id); --添加check约束alter table student add constraint check_sex check (sex in ('男','女'));--check 年龄约束 alter table student add constraint check_age check (age>0 and age<100)--添加not null约束 alter table student modify id constraint not_null_id not null;--添加unique约束 alter table student add constraint unique_id unique(id); --添加default约束alter table student modify note varchar2(100) default'好学生';--增加列alter table student add note2 varchar2(18); alter table student add systemdate date default sysdate not null;--删除列 alter table student drop column note2;--修改列的长度,长度只能由小改成大,如果要改小,则要删除该字段下的值 alter table tab_class2 modify name2 varchar2(500); --修改列的精度 alter table student modify id number(6); --修改列的数据类型 alter table student modify name number(10); --修改列的默认值 alter table student modify systemdate default sysdate+1;--禁用约束 alter table student disable constraint check_age;--启用约束 alter table student enable constraint check_age;--删除约束,如果有外键约束则要先删除外键表中的alter table student drop constraint fk_class_id; --向表中添加注释 comment on table student is '学生表'; --向列添加注释 comment on column student.name is '学生姓名'; comment on column tab_class2.name2 is '班级名'; --清除表中所有数据 truncate table t_student_info; --删除表 drop table t_student_info;
--删除表不经过回收站drop table t_student_info purge;--闪回被删除的表flashback table t_student_info to before drop;
0 0
- 表的基本操作
- 表的基本操作
- 表的基本操作
- 表的基本操作
- 顺序表的基本操作
- 链表的基本操作
- 线性表的基本操作
- 链表的基本操作
- 顺序表的基本操作
- 链表的基本操作
- 顺序表的基本操作
- 顺序表的基本操作
- 链表的基本操作
- 线性表的基本操作
- 顺序表的基本操作
- 链表的基本操作
- 创建表的基本操作
- sql2005表的基本操作
- const char*, char const*, char*const的区别
- Uiautomator中longClick方法时间长度无法调节的解决办法
- 对多线程网络编程的理解
- 快速排序 shell实现
- ssh_exchange_identification: Connection closed by remote
- 表的基本操作
- KindEditor图片上传URL路径处理
- i++和++i 和i+1的区别
- android: 缓存异步加载Bitmap
- 习题3-36
- js校验时间格式
- 关于Linux内核同时运行进程总数的讨论
- tyvj P1209 拦截导弹
- spi slave