Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 由于if不存在,在创建表时缺少或无效选项_Sql_Oracle - Fatal编程技术网

Sql 由于if不存在,在创建表时缺少或无效选项

Sql 由于if不存在,在创建表时缺少或无效选项,sql,oracle,Sql,Oracle,我曾尝试使用sql plus中的mysql创建一个使用if not exists的表,但出现了错误 SQL> CREATE TABLE IF NOT EXISTS tasks ( 2 todo_id int auto_increment, 3 task_id int); CREATE TABLE IF NOT EXISTS tasks ( * 第1行错误: ORA-00922:缺少或无效选项您的消息表明您使用的是Oracles SQL plus,而不是

我曾尝试使用sql plus中的mysql创建一个使用if not exists的表,但出现了错误

SQL> CREATE TABLE IF NOT EXISTS tasks (
  2  todo_id int auto_increment,
  3  task_id int);
CREATE TABLE IF NOT EXISTS tasks (
            *
第1行错误:
ORA-00922:缺少或无效选项

您的消息表明您使用的是Oracles SQL plus,而不是mysql

所以使用

CREATE TABLE tasks (
        todo_id NUMBER  GENERATED BY DEFAULT ON NULL AS IDENTITY,
            task_id NUMBER(5)
      );

请检查手册,查看Oracle中的
CREATE TABLE
语句是否没有
(如果不存在)
选项。请参阅以获取其他选项。
DROP TABLE
的语法如下:错误消息的ORA前缀和对SQL*Plus的引用表明他正在使用Oracle数据库(尽管他说了些什么)。thx@WilliamRobertson我当时心烦意乱,我更正了我的答案