oracle 可以通过序列来完成. CREATE sequence seq_ID
minvalue 1
start with 1
increment by 1
nocache; 通过seq_ID.nextval 取下一个值。
或者写一个触发器:
CREATE or replace trigger insertID_for_news
before insert on news
for each row
BEGIN
select seq_ID.nextval into :new.ID from dual;
END;
/
minvalue 1
start with 1
increment by 1
nocache; 通过seq_ID.nextval 取下一个值。
或者写一个触发器:
CREATE or replace trigger insertID_for_news
before insert on news
for each row
BEGIN
select seq_ID.nextval into :new.ID from dual;
END;
/
id int(10) PRIMARY KEY,
topic varchar(255) NOT NULL ,
body blog NOT NULL ,
hits number(10,0) NOT NULL DEFAULT 0 ,
adddate varchar(30) NOT NULL DEFAULT '0000-00-00 00:00:00' ,
adduser varchar(20) NOT NULL ,
rootid number(4,0) NOT NULL DEFAULT 0 ,
pic varchar(100) ,
) ;
如果有image类型,可以用blob实现.
id int(10) PRIMARY KEY,
topic varchar(255) NOT NULL ,
body blog NOT NULL ,
hits number(10,0) NOT NULL DEFAULT 0 ,
adddate varchar(30) NOT NULL DEFAULT '0000-00-00 00:00:00' ,
adduser varchar(20) NOT NULL ,
rootid number(4,0) NOT NULL DEFAULT 0 ,
pic varchar(100) ,
) ;
这个写的对吗?id int(10) PRIMARY KEY,对吗?
id int(10) PRIMARY KEY
----------------------
这句话不对,oracle没有int数据类型,用number类型代替.
加primary key 可以通过添加约束的方式添加.
在 "pic varchar(100),"这行后面添加: constraint PK_ID primary key(ID)
using index tablespace 索引所在的表空间
storage(initial 40K next 40K pctincrease 1))
tablespace 表所在的表空间名
storage(initial 64k next 64k pctincrease 1); 如果是本地表空间管理模式,就不需要指定storage参数了.
id int(10) PRIMARY KEY,
----------------------
这行改成: id number(10),