zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

NULL和INITIAL的区别 and database interface

Database 区别 and null interface initial
2023-09-14 09:02:51 时间

在用INSERT语句往database table里插入entry时,对于description field(CHAR类型的),如果 不指定任何value,和手动给该field assign value 类似
Ls-description = space, 这两种情况插入到database后的效果一样么?
搞清楚SE11里这个勾是拿来做什么的?
clipboard1

如果table structure append了一个新的structure,那么后面append的对应的字段就会为NULL。就是下面这个link上有个人回复的。我觉得,前半部分是make sense的,但是,他说,这个is null只在where 语句中有效,如果是数据已经选取出来了,放在了internal table里面了,那么就都是initial了。。。
[外链图片转存失败(img-e14KI5kJ-1563802589007)(https://user-images.githubusercontent.com/5669954/32713336-cd09cb64-c883-11e7-95b2-f9db76f1743b.png)]

关于NULL和INITIAL的,做了个实验:

  1. 创建一个新的database table:
    [外链图片转存失败(img-V4r9ftA0-1563802589008)(https://user-images.githubusercontent.com/5669954/32713338-cd3e92a4-c883-11e7-8231-d393dd17d8e3.png)]

  2. 插入两条数据:

[外链图片转存失败(img-pHrG2dkZ-1563802589008)(https://user-images.githubusercontent.com/5669954/32713339-cd75812e-c883-11e7-93e4-e1c7bf52fcc4.png)]

  1. 插入一个include structure, initial value未勾上:

[外链图片转存失败(img-zNwgxUhc-1563802589009)(https://user-images.githubusercontent.com/5669954/32713340-cdae61ba-c883-11e7-9ae1-1ecc1333919d.png)]

  1. 测试:

[外链图片转存失败(img-zdUUZm66-1563802589009)(https://user-images.githubusercontent.com/5669954/32713341-cde1c424-c883-11e7-8628-0c9e24433639.png)]

执行结果:

[外链图片转存失败(img-rKP2l2rV-1563802589010)(https://user-images.githubusercontent.com/5669954/32713342-ce186a74-c883-11e7-958d-5b6d0409c110.png)]

[外链图片转存失败(img-fpCotxAj-1563802589010)(https://user-images.githubusercontent.com/5669954/32713343-ce5025d6-c883-11e7-8721-256b3e8d7a4f.png)]

注:

  1.  上述测试是在QI2/506 ( MaxDB)上做的,如果换到HANA DB上,即使我不勾initial value,所有的IS NOT NULL都会返回true,我也不清楚HANA DB为什么要这样设计。
    
  2.  “刚刚问了一下XXX,她说有一种情况,也是我在做hana preview的时候看到的,就是,如果我们用的是left out join,右边的表里面其实没有对应的数据,那么对应的字段就会显示为NULL.” – 根据ABAP help,只有outer join才会出现你说的情况
    
  3.  “如果是数据已经选取出来了,放在了internal table里面了,那么就都是initial了。。。- 根据ABAP help和我在QI2上的测试,确实如ABAP help说的,NULL 取回internal table之后就自动变成initial了。
    

我猜想“在HANA studio里观察preview的结果”和“在ABAP里使用open SQL将数据取回internal table里”,这两件事不是一回事吧?

ABAP里 写代码去database server取数据要通过database interface:http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3976358411d1829f0000e829fbfe/content.htm