Oracle SQL Developer将我的注释视为命令
我已经创建了一些非常基本的SQL脚本: /* Change date format */ alter session set nls_date_format='DD/MM/YYYY'; /* Drop old tables (if exists) */ DROP TABLE Students; /* Create new tables */ CREATE TABLE Students ( Id NUMBER(6) PRIMARY KEY,LastName VARCHAR2(20),FirstName VARCHAR2(10),Address VARCHAR2(10),BirthDay DATE,GroupId NUMBER(3) ); /* Check the table was created successfully */ DESC Students; /* Insert a new record to the table */ INSERT INTO Students VALUES(101,'Solin','Dan','Beer-Sheva','01/02/1985',11); /* Check the record was inserted succesfully */ SELECT * FROM Students; /* Add 'AvgMark' field to the table with default of 0 */ ALTER TABLE Students ADD AvgMark NUMBER(5,2) DEFAULT 0; /* Check that the new field was added */ DESC Students; /* Insert 3 new records to the table */ INSERT INTO Students VALUES(102,'Tal','Ruti','Tel-Aviv','10/07/1988',12,70); INSERT INTO Students VALUES(103,'Kohen','Yossi','Dimona','01/08/1987',11,80); INSERT INTO Students VALUES(104,'Toys','Vered','15/09/1988',90); /* Check the records were inserted succesfully */ SELECT * FROM Students; /* Change 'Address' data type to VARCHAR2(15) */ ALTER TABLE Students MODIFY Address VARCHAR2(15); /* Check that the data type has changed */ DESC Students; -- Some comment 在脚本输出结束时,我收到此错误消息: 如果我将注释更改为Hello World,我将获得WORLD“object”的相同错误… 我更改了整个脚本以避免单行注释,结果是一样的. 在这个例子中我可以再次避免它,但我真的想了解是什么导致了这个奇怪的问题…… 可能有助于解决问题的另一件事是我在同一个脚本中出现的另一个奇怪的错误,在评论上方几行.在这一行: SQL Developer在最后两个字符(右括号和分号)下显示错误,指出语法错误.部分认可的规则(铁路图):…… 如果我将运行该声明它将工作得很好…… 解决方法这似乎是一个SQL Developer错误/功能.desc [ribe]是SQL Worksheet支持的SQL * Plus语句之一. https://docs.oracle.com/cd/E11882_01/doc.112/e12152/intro.htm#RPTUG10710 在SQL Developer中,我们可以注意到SQL * Plus中不存在的一些有趣的现象: desc some gibberish - yada yada yada t3 Name Null Type ---- ---- ---------- C3 NUMBER(38) 2. – 不被视为行注释的符号,而是作为对象名称. desc -- ERROR: ------------------------------- ERROR: object -- does not exist 3. desc ; ; ; ; ; ; t1; Name Null Type ---- ---- ---------- C1 NUMBER(38) 因此,当给出命令时 – DESC Students; -- Some comment 由于没有对象’comment’,因此只处理最后一个令牌’comment’并产生错误. (编辑:上饶站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |