在oracle livesql中插入行[重复]

1tu0hz3e  于 2023-03-29  发布在  Oracle
关注(0)|答案(1)|浏览(103)

此问题在此处已有答案

(13个答案)
Getting an error ORA-00933: SQL command not properly ended(2个答案)
ORA-00984: column not allowed here while inserting data excluding the sequence trigger(1个答案)
5天前关闭。
我正在对https://livesql.oracle.com/进行试验,但遇到了一个错误。
在执行select * from customers;时,我看到消息no data found
运行INSERT INTO customers (customer_id, customer_name, city) VALUES (1, "name-1","city-1");
我收到错误消息ORA-00984: column not allowed here
这可能是什么原因?我如何在表中插入值?

px9o7tmv

px9o7tmv1#

在Oracle中,字符串用单引号括起来:

INSERT INTO customers (customer_id, customer_name, city) 
VALUES 
(1, 'name-1', 'city-1');

你用双引号把它们括起来;对于Oracle,这意味着您实际指定了列名
一般来说,在使用Oracle时,应该省略双引号(带标识符)并避免大小写混合。

SQL> create table "Test" (ID number, "LastName" varchar2(20));

Table created.

但是你必须在每次访问这样的表时使用双引号并匹配字母大小写:

SQL> insert into test (id, lastname) values (1, 'Littlefoot');
insert into test (id, lastname) values (1, 'Littlefoot')
            *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> insert into "Test" (id, "LastName") values (1, 'Littlefoot');

1 row created.

SQL>

如果你创造了它,

SQL> create table test (id number, LASTnAme varchar2(20));

Table created.

然后你可以用任何你想要的方式写标识符:

SQL> insert into teST (id, lasTNamE) values (1, 'Littlefoot');

1 row created.

SQL>

相关问题