Autor Beitrag
bbfan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: So 29.01.06 13:08 
Hallo Leute!

Ich würde gerne über CREATE TABLE eine Tabelle anlegen, die über 2 PRIMARY KEYs verfügt.

Mein Befehl, der nicht klappt, lautet so:
ausblenden SQL-Anweisung
1:
CREATE TABLE WEIGHT_ORD (NDB_NO CHAR(6PRIMARY KEY,wid INTEGER PRIMARY KEY)					


Delphi meckert mit "Ein PRIMARY KEY gibt es schon..." :-(

Wie lautet der Befehl richtig?

Vielen Dank im Voraus!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 29.01.06 13:41 
Eine Tabelle kann nur einem PK haben, dieser kann aber aus 2 Spalten bestehen.

ausblenden SQL-Anweisung
1:
2:
CREATE TABLE WEIGHT_ORD (NDB_NO CHAR(6),wid INTEGER)
ALTER TABLE WEIGHT_ORD ADD CONSTRAINT PK_WEIGHT_ORD PRIMARY KEY (NDB_NO, wid);

_________________
Markus Kinzler.
bbfan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: So 29.01.06 13:44 
Habe folgende Variante gefunden:
ausblenden SQL-Anweisung
1:
2:
  CREATE TABLE W_TABLE (NDB_NO CHAR(6NOT NULL,wid INTEGER NOT NULL)
  ALTER TABLE W_TABLE  ADD PRIMARY KEY (wid,NDB_NO)


Was hälst du davon?

Vielleicht hast du hierrauf auch ne Antwort: Wie schalte ich nachträglich "leere Zeichenfolge" auf "nein" ?
Danke dir schon mal!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 29.01.06 13:58 
Ich habe in der Schnelle natürlich das NOT NULL beim CREATE Staement vergessen.
Zitat:
Vielleicht hast du hierrauf auch ne Antwort: Wie schalte ich nachträglich "leere Zeichenfolge" auf "nein" ?

mit alter table

_________________
Markus Kinzler.
bbfan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: So 29.01.06 14:01 
aber wie?

NOT NULL bedeutet "Eingabe erforderlich" = "JA"
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 29.01.06 14:08 
NULL statt NOT NULL

_________________
Markus Kinzler.
bbfan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: So 29.01.06 14:10 
Wir missverstehen uns...

Ich möchten den Wert "Leere Zeichenfolge" ändern und nicht den Wert "Eingabe erforderlich".

Die Optionen bei CREATE TABEL mit "NULL" oder "NOT NULL" nehmen nur einfluss auf "Eingabe erforderlich" .
Lassen aber "Leere Zeichenfolge" links liegen.