【发布时间】:2016-04-02 02:35:15
【问题描述】:
我正在尝试将数据从一个表加载到另一个表,从 all_address 加载到客户。
我这样成功地插入到客户表中
INSERT INTO Customer(username, password, customer_email, first_name,
last_name, middle_initial)
SELECT username, password, customer_email, first_name,
last_name, middle_initial
FROM all_user;
但是,每当我尝试通过以下方式获取街道地址、城市和邮政编码时
INSERT INTO Customer(street_address, city, zip_code)
SELECT temp.street_address, temp.city,
temp.zip_code
FROM all_address as temp, Customer as final
WHERE temp.customer_email = final.customer_email;
我收到一个错误:
psql:manip.sql:82: 错误:“用户名”列中的空值违反非空约束
由于用户名是主键,我不明白为什么会出现错误,因为我已确保使用用户名创建客户,因此用户名中没有错误所述的空值。
感谢您的任何帮助!
【问题讨论】:
标签: sql postgresql null