On Fri, Mar 09, 2001 at 03:43:55PM -0300, Marcelo Pereira wrote:
> 
>    Hi,
>    
>    
>    
>    I'm a new user and I would like to know if I can create my table using
>    forein key's.

Sure. Here's an example:

test=> CREATE TABLE statename   (       code CHAR(2) PRIMARY KEY,
test(>                                  name CHAR(30)
test(>                          );
CREATE
test=> INSERT INTO statename VALUES ('AL', 'Alabama');
INSERT 18934 1

test=> CREATE TABLE customer    (
test(>                          customer_id INTEGER,
test(>                          name CHAR(30),
test(>                          telephone CHAR(20),
test(>                          street CHAR(40),
test(>                          city CHAR(25),
test(>                          state CHAR(2) REFERENCES statename,
test(>                          zipcode CHAR(10),
test(>                          country CHAR(20)
test(>                          );
CREATE

(from Bruce Momjian's excellent book on PostgreSQL)

Regards, Frank

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

Reply via email to