/*
intent: test the difference between "DEFAULT NULL" and "DEFAULT 0"
anthor: t0nsha(liaodunxia{at}gmail.com@20081219)
*/
DECLARE
ln_dft_null NUMBER DEFAULT NULL;
ln_dft_zero NUMBER DEFAULT 0;
BEGIN
ln_dft_null := ln_dft_null + 1;
dbms_output.put_line('ln_dft_null = ' || ln_dft_null);
ln_dft_zero := ln_dft_zero + 1;
dbms_output.put_line('ln_dft_zero = ' || ln_dft_zero);
END;
/*dbms_output:
ln_dft_null =
ln_dft_zero = 1
*/
intent: test the difference between "DEFAULT NULL" and "DEFAULT 0"
anthor: t0nsha(liaodunxia{at}gmail.com@20081219)
*/
DECLARE
ln_dft_null NUMBER DEFAULT NULL;
ln_dft_zero NUMBER DEFAULT 0;
BEGIN
ln_dft_null := ln_dft_null + 1;
dbms_output.put_line('ln_dft_null = ' || ln_dft_null);
ln_dft_zero := ln_dft_zero + 1;
dbms_output.put_line('ln_dft_zero = ' || ln_dft_zero);
END;
/*dbms_output:
ln_dft_null =
ln_dft_zero = 1
*/
本文通过PL/SQL示例代码展示了在Oracle数据库中DEFAULT NULL与DEFAULT 0的区别。通过为两个变量分别设置这两种默认值,并进行加一操作,观察并比较其行为差异。

被折叠的 条评论
为什么被折叠?



