Skip site navigation (1) Skip section navigation (2)

Re: Fr?==?iso-8859-1?Q?emdschlüsseln Limit

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-de-allgemein(at)postgresql(dot)org
Subject: Re: Fr?==?iso-8859-1?Q?emdschlüsseln Limit
Date: 2008-12-12 13:48:32
Message-ID: 20081212134832.GF22788@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-de-allgemein
In response to A. Kretschmer :
> In response to Olaf Radicke :
> > Hi!
> > 
> > Frage: Der SQL-Server von Microsoft hat bei Fremdschlüsseln ein Limit von 32. 
> > Hat PostgreSQL ein Limit?
> 
> Was für ein Limit? Anzahl Fremdschlüssel pro Tabelle?
> läuft sauber durch, zu mehr war ich grad zu faul.
> 


test=# create schema limit_test;
CREATE SCHEMA
test=*# set search_path=limit_test;
SET
test=*# create or replace function limit_test(int) returns bool as
$$declare i int; sql text;begin for i in 1..$1 loop execute 'create
table detail'||i||' (id int primary key, name text)'; end loop; sql :=
'create table master_all (id serial primary key, '; for i in 1..$1 loop
if i!=1 then sql:=sql || ','; end if; sql:=sql || ' d'||i||' int
references detail'||i; end loop; sql:=sql || ')'; raise notice '%',sql;
execute sql; return 1::bool; end$$ language plpgsql;
CREATE FUNCTION
test=*# select * from limit_test(1000);


... läuft sauber durch.

Demo mit 3:

test=*# select * from limit_test(3);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"detail1_pkey" for table "detail1"
CONTEXT:  SQL statement "create table detail1 (id int primary key, name
text)"
PL/pgSQL function "limit_test" line 1 at execute statement
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"detail2_pkey" for table "detail2"
CONTEXT:  SQL statement "create table detail2 (id int primary key, name
text)"
PL/pgSQL function "limit_test" line 1 at execute statement
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"detail3_pkey" for table "detail3"
CONTEXT:  SQL statement "create table detail3 (id int primary key, name
text)"
PL/pgSQL function "limit_test" line 1 at execute statement
NOTICE:  create table master_all (id serial primary key,  d1 int
references detail1, d2 int references detail2, d3 int references
detail3)
NOTICE:  CREATE TABLE will create implicit sequence "master_all_id_seq"
for serial column "master_all.id"
CONTEXT:  SQL statement "create table master_all (id serial primary key,
d1 int references detail1, d2 int references detail2, d3 int references
detail3)"
PL/pgSQL function "limit_test" line 1 at execute statement
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"master_all_pkey" for table "master_all"
CONTEXT:  SQL statement "create table master_all (id serial primary key,
d1 int references detail1, d2 int references detail2, d3 int references
detail3)"
PL/pgSQL function "limit_test" line 1 at execute statement
 limit_test
------------
 t
(1 row)

test=*# \d
                   List of relations
   Schema   |       Name        |   Type   |   Owner
------------+-------------------+----------+-----------
 limit_test | detail1           | table    | webmaster
 limit_test | detail2           | table    | webmaster
 limit_test | detail3           | table    | webmaster
 limit_test | master_all        | table    | webmaster
 limit_test | master_all_id_seq | sequence | webmaster
(5 rows)

test=*# \d master_all
                       Table "limit_test.master_all"
 Column |  Type   |                        Modifiers
--------+---------+---------------------------------------------------------
 id     | integer | not null default
nextval('master_all_id_seq'::regclass)
 d1     | integer |
 d2     | integer |
 d3     | integer |
Indexes:
    "master_all_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "master_all_d1_fkey" FOREIGN KEY (d1) REFERENCES detail1(id)
    "master_all_d2_fkey" FOREIGN KEY (d2) REFERENCES detail2(id)
    "master_all_d3_fkey" FOREIGN KEY (d3) REFERENCES detail3(id)



Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

In response to

pgsql-de-allgemein by date

Next:From: Maximilian TyrtaniaDate: 2008-12-12 13:57:01
Subject: Re: Fremdschl=?ISO-8859-1?B?/A==?=sseln Limit
Previous:From: A. KretschmerDate: 2008-12-12 13:29:14
Subject: Re: Fr?==?iso-8859-1?Q?emdschlüsseln Limit

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group