Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Błąd przy tworzeniu tabeli
dexter22
post
Post #1





Grupa: Zarejestrowani
Postów: 23
Pomógł: 1
Dołączył: 16.12.2011

Ostrzeżenie: (10%)
X----


Gdy tworzę

create table pracownicy ( idi varchar2(5) not null constraint references instytut_fkey instytut ); mam taki oto błąd:

constraint specification not allowed here
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
mortus
post
Post #2





Grupa: Zarejestrowani
Postów: 2 178
Pomógł: 596
Dołączył: 25.09.2009
Skąd: Piwniczna-Zdrój

Ostrzeżenie: (0%)
-----


Bo prawidłowo zależności definiujesz tak:
CONSTRAINT nazwa_zależności REFERENCES nazwa_tabeli (opcjonalnie_nazwa_kolumny)
Zatem:
  1. -- tak:
  2. CREATE TABLE pracownicy (
  3. idi varchar2(5) NOT NULL CONSTRAINT instytut_fkey REFERENCES instytut
  4. );
  5. -- lub tak:
  6. CREATE TABLE pracownicy (
  7. idi varchar2(5) NOT NULL CONSTRAINT instytut_fkey REFERENCES instytut (idi)
  8. );
  9. -- lub tak:
  10. CREATE TABLE pracownicy (
  11. idi varchar2(5) NOT NULL,
  12. CONSTRAINT instytut_fkey REFERENCES instytut (idi)
  13. );
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 21:38