在SQL*Plus中,结果集中的显示效果是高度可定制的。如果结果集中包含NULL值,可以使用列格式化命令“NUL[L] text”对其重新定义,以便达到醒目的效果。
1.创建表t,并初始化两条记录,其中第二条包含NULL值
sec@ora10g> create table t (x number(10), y varchar2(30));
Table created.
sec@ora10g> insert into t values (1,'secooler');
1 row created.
sec@ora10g> insert into t values (2,null);
1 row created.
sec@ora10g> commit;
Commit complete.
2.默认情况下显示的效果如下
sec@ora10g> select * from t;
X Y
---------- ------------------------------
1 secooler
2
3.我们对y列格式化,看一下效果
sec@ora10g> col y null "It's NULL"
sec@ora10g> select * from t;
X Y
---------- ------------------------------
1 secooler
2 It's NULL
此时第二行的y列NULL内容显示为“It's NULL”。
4.小结
使用“NUL[L] text”对列进行格式化会带给我们一种便利和神奇的感觉。从此NULL值在SQL*Plus下的控制权尽在掌握。
Good luck.
secooler
10.03.03
-- The End --
1.创建表t,并初始化两条记录,其中第二条包含NULL值
sec@ora10g> create table t (x number(10), y varchar2(30));
Table created.
sec@ora10g> insert into t values (1,'secooler');
1 row created.
sec@ora10g> insert into t values (2,null);
1 row created.
sec@ora10g> commit;
Commit complete.
2.默认情况下显示的效果如下
sec@ora10g> select * from t;
X Y
---------- ------------------------------
1 secooler
2
3.我们对y列格式化,看一下效果
sec@ora10g> col y null "It's NULL"
sec@ora10g> select * from t;
X Y
---------- ------------------------------
1 secooler
2 It's NULL
此时第二行的y列NULL内容显示为“It's NULL”。
4.小结
使用“NUL[L] text”对列进行格式化会带给我们一种便利和神奇的感觉。从此NULL值在SQL*Plus下的控制权尽在掌握。
Good luck.
secooler
10.03.03
-- The End --
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/519536/viewspace-628545/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/519536/viewspace-628545/