SQL 创建表时出现“ORA-00922:缺少或无效的选项”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9858654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"ORA-00922: missing or invalid option" when creating tables
提问by sc1013
I entered the following SQL commands in Oracle but it complained "ORA-00922: missing or invalid option"
我在 Oracle 中输入了以下 SQL 命令,但它抱怨“ORA-00922:缺少或无效的选项”
CREATE TABLE Student (
StuID NUMBER(15),
StuName VARCHAR2(50),
Phone VARCHAR2(20),
PRIMARY KEY (StuID))
CREATE TABLE Program (
ProCode VARCHAR2(12),
ProTitle VARCHAR2(50),
PRIMARY KEY (ProCode))
WHY???
为什么???
回答by a_horse_with_no_name
If you are using the dreaded HTML GUI (inside the browser) of OracleXE then that does not support running more than one statement.
如果您使用 OracleXE 可怕的 HTML GUI(在浏览器中),那么它不支持运行多个语句。
Use SQL Developer, SQL*Plus or any other GUI tool instead.
请改用 SQL Developer、SQL*Plus 或任何其他 GUI 工具。
回答by egrunin
回答by Dor Cohen
Try no to define the size of StuID. also add constraint key work and just to make sure use DROP before CREATE like this:
尝试 no 来定义 StuID 的大小。还添加约束键工作,并确保在 CREATE 之前使用 DROP,如下所示:
DROP TABLE Student;
CREATE TABLE Student (
StuID NUMBER,
StuName VARCHAR2(50),
Phone VARCHAR2(20),
constraint pk_Student PRIMARY KEY (StuID));
DROP TABLE Program;
CREATE TABLE Program (
ProCode VARCHAR2(12),
ProTitle VARCHAR2(50),
constraint pk_Program PRIMARY KEY (ProCode));