使用批量插入时插入空值 [英] Inserting null values when using bulk insert

查看:115
本文介绍了使用批量插入时插入空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子:

CREATE TABLE cust (
    cust_id NOT NULL,
    cust_name NOT NULL,
    address NULL
);

我必须将这些行插入另一个表:

I have to insert these rows into another table:

CREATE TABLE 1cust_det (
    cust_id NOT NULL,
    cust_name NOT NULL,
    address NOT NULL
);

不幸的是,cust.address列包含NULL值.我想使用光标将这些行从cust插入到1cust_det.我该怎么办?

Unfortunately the cust.address column contains NULL values. I want to insert these rows from cust to 1cust_det using a cursor. What do I have to do?

推荐答案

INSERT INTO
    cust_det
SELECT
    cust_id,
    cust_name,
    COALESCE(address, 'UNKNOWN')
FROM
    cust

这篇关于使用批量插入时插入空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆