mysql和oracle建表语句的区别

时间:2022-11-12 08:42:12

mysql

DROP TABLE IF EXISTS `order`;
CREATE TABLE `order` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `number` varchar(255) NOT NULL COMMENT '工单编号',
  `applicant` varchar(255) NOT NULL COMMENT '工单申请人',
  `state` int(1) NOT NULL COMMENT '工单状态',
  `count` int(4) NOT NULL COMMENT '个数',
  `ctime` varchar(255) NOT NULL,
  `depart` varchar(255) NOT NULL COMMENT '部门',
  `projectname` varchar(255) NOT NULL COMMENT '项目名称',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8;

 

oracle

---创建表
create table ZHANGSAN.ORDER
(
  id           NUMBER not null,
  number    VARCHAR2(255),
  applicant VARCHAR2(255),
  state     NUMBER(1),
  count     NUMBER(6),
  ctime     VARCHAR2(30),
  depart    VARCHAR2(255),
  projectname  VARCHAR2(255)
)

---为每一行添加注释
comment on column ZHANGSAN.ORDER.number
  is '工单编号';
comment on column ZHANGSAN.ORDER.applicant
  is '工单申请人';
comment on column ZHANGSAN.ORDER.state
  is '工单状态';
comment on column ZHANGSAN.ORDER.count
  is '个数';
comment on column ZHANGSAN.ORDER.ctime
  is '创建时间';
comment on column ZHANGSAN.ORDER.depart
  is '部门';
comment on column ZHANGSAN.ORDER.projectname
  is '项目名称';
 
 
---指定主键  
alter table ZHANGSAN.ORDER
  add constraint ID primary key (ID)
  using index
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255;