FremdschlüsselnLimit
am 12.12.2008 14:12:38 von Olaf Radicke
Hi!
Frage: Der SQL-Server von Microsoft hat bei Fremdschlüsseln ein Limit =
von 32.=20
Hat PostgreSQL ein Limit?
MfG
Olaf
--=20
Meine Rechtschreibfehler stehen unter der Creative Commons Lizenz.
(Bearbeitungen und Weitergabe unter gleichen Bedingungen):
http://creativecommons.org/licenses/by-sa/2.0/de/
--=20
Sent via pgsql-de-allgemein mailing list (pgsql-de-allgemein@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-de-allgemein
Re: Fr
am 12.12.2008 14:29:14 von andreas.kretschmer
In response to Olaf Radicke :
> Hi!
>=20
> Frage: Der SQL-Server von Microsoft hat bei Fremdschlüsseln ein Limit=
von 32.=20
> Hat PostgreSQL ein Limit?
Was für ein Limit? Anzahl Fremdschlüssel pro Tabelle?
create table detail1(id serial primary key);
create table detail2(id serial primary key);
create table detail3(id serial primary key);
....
create table detail38(id serial primary key);
create table detail39(id serial primary key);
create table detail40(id serial primary key);
create table master_all(
d1 int references detail1,
d2 int references detail2,
d3 int references detail3,
....
d38 int references detail38,
d39 int references detail39,
d40 int references detail40
);
läuft sauber durch, zu mehr war ich grad zu faul.
Andreas
--=20
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
--=20
Sent via pgsql-de-allgemein mailing list (pgsql-de-allgemein@postgresql.o=
rg)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-de-allgemein
Re: Fr
am 12.12.2008 14:48:32 von andreas.kretschmer
In response to A. Kretschmer :
> In response to Olaf Radicke :
> > Hi!
> >=20
> > Frage: Der SQL-Server von Microsoft hat bei Fremdschlüsseln ein Lim=
it von 32.=20
> > Hat PostgreSQL ein Limit?
>=20
> Was für ein Limit? Anzahl Fremdschlüssel pro Tabelle?
> läuft sauber durch, zu mehr war ich grad zu faul.
>=20
test=3D# create schema limit_test;
CREATE SCHEMA
test=3D*# set search_path=3Dlimit_test;
SET
test=3D*# 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 :=3D
'create table master_all (id serial primary key, '; for i in 1..$1 loop
if i!=3D1 then sql:=3Dsql || ','; end if; sql:=3Dsql || ' d'||i||' int
references detail'||i; end loop; sql:=3Dsql || ')'; raise notice '%',sql;
execute sql; return 1::bool; end$$ language plpgsql;
CREATE FUNCTION
test=3D*# select * from limit_test(1000);
.... läuft sauber durch.
Demo mit 3:
test=3D*# 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=3D*# \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=3D*# \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
--=20
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
--=20
Sent via pgsql-de-allgemein mailing list (pgsql-de-allgemein@postgresql.o=
rg)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-de-allgemein