如下的 t—sql 建表 语句 ,用oracle 的建表语句该怎么改啊
CREATE TABLE [channel]([Id] [int] IDENTITY (1, 1) NOT NULL ,[ChID] [int] NOT NULL ,
[SpecialID] [nvarchar] (200) NULL ,[TitleITF] [tinyint] NULL,
[Content] [ntext] NULL ,[GroupNumber] [ntext] NULL ,
[CreatTime] [datetime] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] ALTER TABLE [channel]
WITH NOCHECK ADD CONSTRAINT [channel] PRIMARY KEY CLUSTERED([Id]) ON [PRIMARY]
CREATE TABLE [channel]([Id] [int] IDENTITY (1, 1) NOT NULL ,[ChID] [int] NOT NULL ,
[SpecialID] [nvarchar] (200) NULL ,[TitleITF] [tinyint] NULL,
[Content] [ntext] NULL ,[GroupNumber] [ntext] NULL ,
[CreatTime] [datetime] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] ALTER TABLE [channel]
WITH NOCHECK ADD CONSTRAINT [channel] PRIMARY KEY CLUSTERED([Id]) ON [PRIMARY]
--参考:
CREATE TABLE channel(
Id int primary key ,
ChID int NOT NULL ,
SpecialID varchar2(200) NULL ,
TitleITF int NULL,
Content clob NULL ,
GroupNumber clob NULL ,
CreatTime date NULL )
oracle里都用number了,如:id number(5)
oracle自增比较麻烦,需要使用序列加触发器。
SQL> create table a(id number,name varchar2(20));
Table created
SQL> create sequence seq_a_id start with 1 increment by 1;
Sequence created
SQL> create or replace trigger tr_a
2 before insert on a
3 for each row
4 begin
5 select seq_a_id.nextval into :new.id from dual;
6 end;
7 /
Trigger created
SQL> insert into a(name) values('aa');
1 row inserted
SQL> insert into a(name) values('bb');
1 row inserted
SQL> select * from a;
ID NAME
---------- --------------------
1 aa
2 bb
SQL>