M
Mark Lai
Unregistered / Unconfirmed
GUEST, unregistred user!
我正在学习数据库,丛书上看了个例子,说是么用SQL来建立几个文件,
相关的SQL语言如下:
CREATE GOOD
(GNO CHAR(6) CONSTRAINT CONGNO PRIMARY KEY,
GNAME CHAR(6) ,
GNM NUMBER(4),
GPRICE NUMBER(3),
GOWNER CHAR(10)
SNO CHAR(4) CONSTRAINT COUNUSER REFERENCES STORE(SNO)
);
CREATE STORE
(SNO CHAR(4) CONSTRAINT CONSNO PRIMARY KEY,
SNAME CHAR(6) CONSTRAINT CONNAME REFERENCES GOOD(GNAME),
SHEAD CHAR(10),
SLOCATION CHAR(10)
);
CREATE IMPORT
(INO NUMBER(3) CONSTRAINT CONINO PRIMARY KEY,
GNO CHAR(6) CONSTRAINT CONGNO REFERENCES GOOD(GNO),
GNUM NUMBER(4) CONSTRAINT GONNUM REFERENCES GOOD(GNUM),
GPRICE NUMBER(3) CONSTRAINT CONPRICE REFERENCES GOOD(GPRICE),
GOWNER CHAR(10) CONSTRAINT CONOWNER REFERENCES GOOD(GOWNER),
SNO CHAR(4) CONSTRAINT CONUSER REFERENCES STORE(SNO),
DATE DATE
);
CREATE EXPORT
(ENO NUMBER(3) CONSTRAINT CONENO PRIMARY KEY,
GNO CHAR(6) CONSTRAINT CONGNO REFERENCES GOOD(GNO),
GNUM NUMBER(4) CONSTRAINT CONNUM REFERENCES GOOD(GNUM),
GPRICE NUMBER(3) CONSTRAINT CONPRICE REFERENCES GOOD(GPRICE),
GOWNER CHAR(10) CONSTRAINT CONOWNER REFERENCES GOOD(GOWNER),
SNO CHAR(4) CONSTRAINT CONUSER REFERENCES STORE(SNO)
DATE DATE
);
这样是么建立4个表,但是书上没说清楚具体应该在那里用这些SQL语言。
我试过在Database Desktop里建立一个SQL文件,然后在Database Desktop里执行它,
但是却报错。于是我在delphi里将这些代码填入Query控件地sql属性里,然后想用一个
按钮调用Query控件的ExecSQL方法,但是却无法编译,错误信息为“Invalid use of
keyword Token:good
(GNO
line number 1
请教各位到底是怎么回事?
应该怎么使用这些SQL代码?
相关的SQL语言如下:
CREATE GOOD
(GNO CHAR(6) CONSTRAINT CONGNO PRIMARY KEY,
GNAME CHAR(6) ,
GNM NUMBER(4),
GPRICE NUMBER(3),
GOWNER CHAR(10)
SNO CHAR(4) CONSTRAINT COUNUSER REFERENCES STORE(SNO)
);
CREATE STORE
(SNO CHAR(4) CONSTRAINT CONSNO PRIMARY KEY,
SNAME CHAR(6) CONSTRAINT CONNAME REFERENCES GOOD(GNAME),
SHEAD CHAR(10),
SLOCATION CHAR(10)
);
CREATE IMPORT
(INO NUMBER(3) CONSTRAINT CONINO PRIMARY KEY,
GNO CHAR(6) CONSTRAINT CONGNO REFERENCES GOOD(GNO),
GNUM NUMBER(4) CONSTRAINT GONNUM REFERENCES GOOD(GNUM),
GPRICE NUMBER(3) CONSTRAINT CONPRICE REFERENCES GOOD(GPRICE),
GOWNER CHAR(10) CONSTRAINT CONOWNER REFERENCES GOOD(GOWNER),
SNO CHAR(4) CONSTRAINT CONUSER REFERENCES STORE(SNO),
DATE DATE
);
CREATE EXPORT
(ENO NUMBER(3) CONSTRAINT CONENO PRIMARY KEY,
GNO CHAR(6) CONSTRAINT CONGNO REFERENCES GOOD(GNO),
GNUM NUMBER(4) CONSTRAINT CONNUM REFERENCES GOOD(GNUM),
GPRICE NUMBER(3) CONSTRAINT CONPRICE REFERENCES GOOD(GPRICE),
GOWNER CHAR(10) CONSTRAINT CONOWNER REFERENCES GOOD(GOWNER),
SNO CHAR(4) CONSTRAINT CONUSER REFERENCES STORE(SNO)
DATE DATE
);
这样是么建立4个表,但是书上没说清楚具体应该在那里用这些SQL语言。
我试过在Database Desktop里建立一个SQL文件,然后在Database Desktop里执行它,
但是却报错。于是我在delphi里将这些代码填入Query控件地sql属性里,然后想用一个
按钮调用Query控件的ExecSQL方法,但是却无法编译,错误信息为“Invalid use of
keyword Token:good
(GNO
line number 1
请教各位到底是怎么回事?
应该怎么使用这些SQL代码?