序列、索引

自增序列
-- Create sequence 
create sequence SDICT_ID
minvalue 1
maxvalue 99999999
start with 193
increment by 1
cache 16
order;


oracle索引

-- Create table
create 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 stuMarks
create 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值