pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: constrains questios ..
3+ messages / 2 participants
[nested] [flat]
* Re: constrains questios ..
@ 2003-02-11 16:48 Johannes Lochmann <johannes.lochmann@chello.at>
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Lochmann @ 2003-02-11 16:48 UTC (permalink / raw)
To: pgsql-sql
On Tuesday 11 February 2003 16:35, Rafal Kedziorski wrote:
Hi,
> is better to create constrains while creating table or after the table
> is created? I'm working on sql script which should create about 40 tables.
I usually first create the tables, then the constraints. Rational: You can
create the tables in any sequence you want to.
HTH
Johannes Lochmann
--
Disclaimer - These opiini^H^H damn! ^H^H ^Q ^[ .. :w :q :wq :wq! ^d X^?
exit X Q ^C ^c ^? :quitbye CtrlAltDel ~~q :~q logout save/quit :!QUIT
^[zz ^[ZZZZZZ ^H man vi ^@ ^L ^[c ^# ^E ^X ^I ^T ? help helpquit ^D ^d
man help ^C exit ?Quit ?q CtrlShftDel "Hey, what does this button d..."
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: constrains questios ..
@ 2003-02-11 17:41 Matthew Nuzum <cobalt@bearfruit.org>
parent: Johannes Lochmann <johannes.lochmann@chello.at>
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Nuzum @ 2003-02-11 17:41 UTC (permalink / raw)
To: 'Johannes Lochmann' <johannes.lochmann@chello.at>; pgsql-sql
> > is better to create constrains while creating table or after the
table
> > is created? I'm working on sql script which should create about 40
> tables.
>
> I usually first create the tables, then the constraints. Rational: You
can
> create the tables in any sequence you want to.
>
> HTH
>
> Johannes Lochmann
>
Can you please demonstrate the syntax you would use to create the
constraints? I'm not real clear on this and my attempts haven't
produced what I wanted.
--
Matthew Nuzum
www.bearfruit.org
cobalt@bearfruit.org
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: constrains questios ..
@ 2003-02-11 18:04 Johannes Lochmann <johannes.lochmann@chello.at>
parent: Matthew Nuzum <cobalt@bearfruit.org>
0 siblings, 0 replies; 3+ messages in thread
From: Johannes Lochmann @ 2003-02-11 18:04 UTC (permalink / raw)
To: Matthew Nuzum <cobalt@bearfruit.org>; pgsql-sql
On Tuesday 11 February 2003 18:41, Matthew Nuzum wrote:
> Can you please demonstrate the syntax you would use to create the
> constraints? I'm not real clear on this and my attempts haven't
> produced what I wanted.
Checked the docs? They are really good at this point. Anyways.
The following creates Tables A, B and AB. A and B have an id and a text field,
AB connects them (N:M relation).
create table A (
id integer not null primary key,
something varchar(16)
);
create table B (
id integer not null primary key,
otherthing varchar(16)
);
create table AB (
id_a integer not null,
id_b integer not null,
constraint pk_AB primary key(id_a, id_b)
);
create unique index u_A_something on A (something);
create unique index u_A_otherthing on B (otherthing);
alter table AB add constraint fk_AB_A_exists foreign key(id_a) references
A(id);
alter table AB add constraint fk_AB_B_exists foreign key(id_b) references
B(id);
HTH
Johannes Lochmann
--
Disclaimer - These opiini^H^H damn! ^H^H ^Q ^[ .. :w :q :wq :wq! ^d X^?
exit X Q ^C ^c ^? :quitbye CtrlAltDel ~~q :~q logout save/quit :!QUIT
^[zz ^[ZZZZZZ ^H man vi ^@ ^L ^[c ^# ^E ^X ^I ^T ? help helpquit ^D ^d
man help ^C exit ?Quit ?q CtrlShftDel "Hey, what does this button d..."
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-02-11 18:04 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-11 16:48 Re: constrains questios .. Johannes Lochmann <johannes.lochmann@chello.at>
2003-02-11 17:41 ` Matthew Nuzum <cobalt@bearfruit.org>
2003-02-11 18:04 ` Johannes Lochmann <johannes.lochmann@chello.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox