|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Aug 2002
Città: Pisa-Napoli
Messaggi: 175
|
Problema con la creazione di database in SQL
Il mio problema e che adesso mi sto affacciando al mondo della programmazione in SQL ho questo problema. I dati sono copiati da un manuale della Jackson e non capisco l'errore che mi da' in ambiente console.
create table Salespersons (empid integer not null primary key, ename char(15) not null, rank integer not null default 1 check (rank IN (1,2,3)), salary decimal(5,2) not null default 100.00 check (salary >=100.00)); create table Customers (custid integer not null primary key, cname char(15) not null, credit char(1) not null check (credit IN ('A','B','C'))); create table Inventory (partid integer not null primary key, descriprion char (10) not null, stockqty integer not null, recorderpnt integer, price decimal(5,2) not null); create table Orders (ordersid INTEGER not null primary key, empid INTEGER not null references salespersons(empid), custid INTEGER not null references customers(custid), salesdate DATE NOT NULL DEFAULT CURRENT_DATE, item1 INTEGER REFERENCES Inventory(partid), qty1 INTEGER, item2 INTEGER REFERENCES Inventory(partid), qty2 INTEGER, item3 INTEGER REFERENCES Inventory(partid), qty3 INTEGER, item4 INTEGER REFERENCES Inventory(partid), qty4 INTEGER, item5 INTEGER REFERENCES Inventory(partid), qty5 INTEGER); mi da questo messaggio Server: messaggio 156, livello 15, stato 1, riga 24 Sintassi non corretta in prossimità della parola chiave 'CURRENT_DATE'. Grazie per l'aiuto
__________________
Centrino con win_2k pro e ubuntu 7.10. Ho Venduto una psp fat a The_Dave, feedbeack ottimo. |
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Aug 2001
Città: Gerenzano
Messaggi: 129
|
Se usi SQL Server 7.00 o il 2000 mi sà che ci sono 2 errori ...
create table Orders (ordersid INTEGER not null primary key, empid INTEGER not null references salespersons(empid), custid INTEGER not null references customers(custid), salesdate DATE NOT NULL DEFAULT CURRENT_DATE , item1 INTEGER REFERENCES Inventory(partid), qty1 INTEGER, item2 INTEGER REFERENCES Inventory(partid), qty2 INTEGER, item3 INTEGER REFERENCES Inventory(partid), qty3 INTEGER, item4 INTEGER REFERENCES Inventory(partid), qty4 INTEGER, item5 INTEGER REFERENCES Inventory(partid), qty5 INTEGER) 1) Non esiste la funzione CURRENT_DATE, usa invece GETDATE 2) Non esiste il dataType DATE,usa invece DATETIME ... forse il libro è stato scritto basandosi su una sitassi standard SQL, ma alcune "piccolezze" tipo i datatype ecc.. possono variare a seconda della piattaforma che usi (Oracle,SQL,Access ecc...) Ciao.
__________________
E' quasi tutto relativo! |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 08:09.


















