序列、索引

来源:互联网 发布:端游发展史 知乎 编辑:程序博客网 时间:2024/06/07 10:49
自增序列
-- Create sequence create sequence SDICT_IDminvalue 1maxvalue 99999999start with 193increment by 1cache 16order;

oracle索引

-- Create tablecreate table DICT(  id    NUMBER(8) not null,  type  VARCHAR2(32),  name  VARCHAR2(64),  value VARCHAR2(32))tablespace GBITS  pctfree 10  initrans 1  maxtrans 255  storage  (    initial 64K    next 1M    minextents 1    maxextents unlimited  );-- Create/Recreate primary, unique and foreign key constraints alter table DICT  add constraint PK_DICT_ID primary key (ID)  using index   tablespace GBITS  pctfree 10  initrans 2  maxtrans 255  storage  (    initial 64K    next 1M    minextents 1    maxextents unlimited  );



mysql:

  1. DROP TABLE IF EXISTS `workers_info`;  
  2. CREATE TABLE `workers_info` (  
  3.   `id` int(11) primary key NOT NULL AUTO_INCREMENT,  
  4.   `workername` varchar(20) NOT NULL,  
  5.   `sex` enum(F,M,S),  
  6.   `salary` int(11) DEFAULT '0',  
  7.   `email`  varchar(30),  
  8.   `EmployedDates`  date,  
  9.   `department`  varchar(30),  
  10.   PRIMARY KEY (`id`)  
  11. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;  
  12.   
  13.   
  14. mysql> alter table workers_info ADD sex  enum('F','M','S');  

ALTER TABLE table_name ADD INDEX index_name (column_list)

ALTER TABLE table_name ADD UNIQUE (column_list)

ALTER TABLE table_name ADD PRIMARY KEY (column_list)

sqlserver:

drop table stuMarkscreate table stuMarks(    ExamNo      int     identity(1,1) primary key,    stuNo       char(6) not null,    writtenExam int     not null,    LabExam     int     not null)go-- 其中,列属性"identity(起始值,递增量)" 表示"ExamNo"列为自动编号, 也称为标识列
ALTER TABLE cust_id ADD cust_id_seq number(9) identity(1,1)

0 0