ITPub博客

首页 > IT职业 > IT生活 > 傻瓜问题。

傻瓜问题。

原创 IT生活 作者:sgwshi 时间:2012-09-13 15:01:59 0 删除 编辑

create table te(id number(10) constraint abc primary key)

create table te(id number(10) constraint abc check (id >0);

语法问题纠结了半个小时.

将一个表移到到另一个表空间

alter table table_name move tablespace tablespace_name;

同时需要重建索引。

alter index index_name rebuild tablespace tablespace_name;

[@more@]

创建表的语法
-创建表格语法:
create table 表名(
字段名1 字段类型(长度) 是否为空,
字段名2 字段类型 是否为空
);

-增加主键
alter table 表名 add constraint 主键名 primary key (字段名1);

-增加外键:
alter table 表名
add constraint 外键名 foreign key (字段名1)
references 关联表 (字段名2);

在建立表格时就指定主键和外键

create table T_STU (
STU_ID char(5) not null,
STU_NAME varchar2(8) not null,
constraint PK_T_STU primary key (STU_ID)
);


主键和外键一起建立:
create table T_SCORE (
EXAM_SCORE number(5,2),
EXAM_DATE date,
AUTOID number(10) not null,
STU_ID char(5),
SUB_ID char(3),
constraint PK_T_SCORE primary key (AUTOID),
constraint FK_T_SCORE_REFE foreign key (STU_ID)
references T_STU (STU_ID)
)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27784356/viewspace-1059411/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: ORA-12514错误
请登录后发表评论 登录
全部评论
  • 博文量
    11
  • 访问量
    18688