Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f92AYPn23634 for ; Tue, 2 Oct 2001 06:34:25 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f92AW0Z01499 for pgsql-sql@postgresql.org; Tue, 2 Oct 2001 06:32:00 -0400 (EDT) (envelope-from news) From: Nils Zonneveld X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Stupid Question Date: Tue, 02 Oct 2001 12:30:12 +0200 Organization: Nilsies little old network Lines: 57 Message-ID: <3BB99732.4BBC83C@mbit.nl> References: <9pc2t6$31ga$1@news.tht.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@cistron.nl X-Mailer: Mozilla 4.75 (Macintosh; U; PPC) X-Accept-Language: nl,en To: pgsql-sql@postgresql.org X-Archive-Number: 200110/18 X-Sequence-Number: 4973 Rebekah Kirk wrote: > > I want to create a table and for whatever reason it will not accept the > command, can anyone say what is wrong as I am very new to Postgres, thanks: > > CREATE TABLE cmpnycontacts ( > ContactNo integer(10) NOT NULL SERIAL, > CmpnyNo varchar(6) NOT NULL, > FirstName varchar(30) NOT NULL, > Surname varchar(30) NOT NULL, > Phone varchar(20) NOT NULL, > Mobile varchar(20) NOT NULL, > Email varchar(40) NOT NULL, > Country char(2) NOT NULL, > CONSTRAINT cmpnycontacts_pkey PRIMARY KEY (ContactNo) > ); Your problem is with the ContactNo, two things: - there is no specified length for 'integer', so integer(10) would fail (integer is defined IIRC as int4, meaning an integer that uses four bytes to store its values). - the SERIAL keyword defines a integer coupled to a sequence. The following statement would work: CREATE TABLE cmpnycontacts ( ContactNo SERIAL primary key, CmpnyNo varchar(6) NOT NULL, FirstName varchar(30) NOT NULL, Surname varchar(30) NOT NULL, Phone varchar(20) NOT NULL, Mobile varchar(20) NOT NULL, Email varchar(40) NOT NULL, Country char(2) NOT NULL ); Its looks like this table has a relationship to a table that holds the company data. Since PostgreSQL supports referential integrity you could extend CmpnyNo in the following way: CmpnyNo varchar(6) not null references Company on update cascade on delete cascade, Hope this helps, Nils Zonneveld -- Alles van waarde is weerloos Lucebert