博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle建表
阅读量:4635 次
发布时间:2019-06-09

本文共 1753 字,大约阅读时间需要 5 分钟。

参考网址:http://www.oraclejsq.com/article/010100139.html

-- Create tablecreate table STUDENT.stuinfo(  stuid      varchar2(10) not null,--学号:'S'+班号(6位数)+学生序号(3位数)(1)  stuname    varchar2(50) not null,--学生姓名  sex        char(1) not null,--性别  age        number(2) not null,--年龄  classno    varchar2(6) not null,--班号:年级(4位数)+班级序号(2位数)  stuaddress varchar2(100) default '地址未录入',--地址 (2)  grade      char(4) not null,--年级  enroldate  date,--入学时间  idnumber   varchar2(18) default '身份证未采集' not null--身份证)tablespace USERS --(3)  storage  (    initial 64K    minextents 1    maxextents unlimited  );-- Add comments to the table comment on table STUDENT.stuinfo --(4)  is '学生信息表';-- Add comments to the columns comment on column STUDENT.stuinfo.stuid -- (5)  is '学号';comment on column STUDENT.stuinfo.stuname  is '学生姓名';comment on column STUDENT.stuinfo.sex  is '学生性别';comment on column STUDENT.stuinfo.age  is '学生年龄';comment on column STUDENT.stuinfo.classno  is '学生班级号';comment on column STUDENT.stuinfo.stuaddress  is '学生住址';comment on column STUDENT.stuinfo.grade  is '年级';comment on column STUDENT.stuinfo.enroldate  is '入学时间';comment on column STUDENT.stuinfo.idnumber  is '身份证号';

 

-- Create/Recreate primary, unique and foreign key constraints alter table STUDENT.STUINFO  add constraint pk_stuinfo_stuid primary key (STUID);  --把stuid单做主键,主键字段的数据必须是唯一性的(学号是唯一的)  -- Create/Recreate check constraints alter table STUDENT.STUINFO  add constraint ch_stuinfo_age  check (age>0 and age<=50);--给字段年龄age添加约束,学生的年龄只能0-50岁之内的  alter table STUDENT.STUINFO  add constraint ch_stuinfo_sex  check (sex='1' or sex='2');  alter table STUDENT.STUINFO  add constraint ch_stuinfo_GRADE  check (grade>='1900' and grade<='2999');

转载于:https://www.cnblogs.com/hf1314/p/9746490.html

你可能感兴趣的文章
meson 中调用shell script
查看>>
相关博客
查看>>
Servlet运行原理以及生命周期
查看>>
Linux学习之三-Linux系统的一些重要配置文件
查看>>
转 [JAVA] 使用 common-fileupload 实现文件上传
查看>>
十五天精通WCF——第三天 client如何知道server提供的功能清单
查看>>
构建之法阅读笔记04
查看>>
Python - selenium_WebDriver 鼠标键盘事件
查看>>
oracle创建DBLink连接
查看>>
spark+openfire即时通讯工具二次开发参考文档
查看>>
java.util.concurrent包API学习笔记
查看>>
从技术细节看美团的架构
查看>>
Odoo进销存业务学习笔记
查看>>
c++标准库 及 命名空间std
查看>>
【POJ1113】Wall(凸包)
查看>>
SD.Team颜色代码大全
查看>>
使用按钮控制HTML5背景音乐开关
查看>>
[spring-boot] 多环境配置
查看>>
mongodb插入数据获取本次插入的mongodb id
查看>>
JAVA面试相关基础知识
查看>>