使用主键更新表字段

时间:2018-12-01 21:29:28

标签: sql oracle

你好,我认为这应该很容易,但是我很沮丧。我正在尝试更新表中的某些名称,并且我想使用主键字段来更新名称,但是我正在更新0行。

UPDATE customers SET last_name='Smith' WHERE customer_id = 11;

1 个答案:

答案 0 :(得分:0)

--drop table customers;

create table customers (
    CUSTOMER_ID NUMBER(6) NOT NULL,
    LAST_NAME VARCHAR2(20) NOT NULL
);

insert into Customers(CUSTOMER_ID, LAST_NAME) values(11, 'Doe');

select count(*) from Customers WHERE customer_id = 11;

UPDATE customers SET last_name='Smith' WHERE customer_id = 11;

UPDATE customers SET last_name='Smith' WHERE customer_id = 11;

写入(在全部选定并作为脚本执行时-F5):

Table CUSTOMERS created.


1 row inserted.


  COUNT(*)
----------
         1


1 row updated.


1 row updated.

在Oracle 12c的控制台中。