Обсуждение: Create table syntax

Поиск
Список
Период
Сортировка

Create table syntax

От
"satish rao "
Дата:
Hi

Entered below is the SQL create table syntax:

CREATE TABLE lists ([listid] [int] IDENTITY (1, 1) NOT NULL ,[listname] [varchar] (200) NULL ,[listcreator] [varchar]
(200)NULL ,[listdesc] [text] NULL) 


We need to know that this syntax will work properly in
postgresql while creating the table and the
autoincrement option for the column(listid). If this
syntax is not correct for postgresql, we need the
correct syntax.

Hoping for a positive response from ur side.

Regards

Satish Rao












Re: Create table syntax

От
Arne Weiner
Дата:
satish rao wrote:
> 
> Hi
> 
> Entered below is the SQL create table syntax:
> 
> CREATE TABLE lists (
>         [listid] [int] IDENTITY (1, 1) NOT NULL ,
>         [listname] [varchar] (200) NULL ,
>         [listcreator] [varchar] (200) NULL ,
>         [listdesc] [text] NULL)
> 
> We need to know that this syntax will work properly in=20
> postgresql while creating the table and the=20
> autoincrement option for the column(listid). If this=20
> syntax is not correct for postgresql, we need the=20
> correct syntax.
> 
CREATE TABLE lists (        listid SERIAL NOT NULL ,        listname varchar(200) NULL ,        listcreator
varchar(200)NULL ,        listdesc text NULL);
 
This create statement is accepted from postgres. The type SERIAL does
theautoincremention. This Statement should do what you want.


Arne.


Re: Create table syntax

От
Stephan Szabo
Дата:
On 28 Aug 2001, satish rao  wrote:

> Entered below is the SQL create table syntax:
> 
> CREATE TABLE lists (
>     [listid] [int] IDENTITY (1, 1) NOT NULL ,
>     [listname] [varchar] (200) NULL ,
>     [listcreator] [varchar] (200) NULL ,
>     [listdesc] [text] NULL)

create table lists (listid serial not null,listname varchar(200),listcreator varchar(200),listdesc text);

(You may want to make listid a primary key as well)