Difference between revisions of "SET NULL"

From Lianjapedia
Jump to: navigation, search
m (1 revision: SQL)
(Description)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
To determine NULL value support
 
To determine NULL value support
 
  
 
==Syntax==
 
==Syntax==
 
SET NULL ON | OFF
 
SET NULL ON | OFF
 
  
 
==See Also==
 
==See Also==
[[ALTER TABLE]], [[CREATE TABLE]], [[EMPTY()]], [[INSERT]], [[ISBLANK()]], [[ISNULL()]], [[NVL()]], [[SET NULLDISPLAY]], [[SET SQL]]
+
[[ALTER TABLE]], [[COALESCE()]], [[CREATE TABLE]], [[EMPTY()]], [[INSERT]], [[ISBLANK()]], [[ISNULL()]], [[NVL()]], [[SET NULLDISPLAY]]
 
+
  
 
==Description==
 
==Description==
The SET NULL ON | OFF command is used to determine whether columns in a table support NULL values.  With SET NULL ON, table columns will support NULL values by default.  INSERT will insert a NULL into any column that does not have a value specified.  With SET NULL off, NULL values are not supported by default.  INSERT will insert a NULL into any column that does not have a value specified..  This default can be overridden by specifying the NULL or NOT NULL column constraint on an individual column.
+
The SET NULL ON | OFF command is used to determine whether columns in a table support NULL values.  With SET NULL ON, table columns will support NULL values by default.  INSERT will insert a NULL into any column that does not have a value specified.  With SET NULL off, NULL values are not supported by default.  This default can be overridden by specifying the NULL or NOT NULL column constraint on an individual column.
 
+
SET NULL is OFF by default.
+
 
+
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
set sql to vfp
 
 
set null on
 
set null on
 
CREATE TABLE nullon (firstname c(20), lastname c(20))
 
CREATE TABLE nullon (firstname c(20), lastname c(20))
Line 58: Line 51:
 
</code>
 
</code>
  
 
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 
[[Category:Set_Commands|NULL]]
 
[[Category:Set_Commands|NULL]]
 
[[Category:SQL]]
 
[[Category:SQL]]
[[Category:SQL Set Commands]]
 

Latest revision as of 10:50, 26 November 2020

Purpose

To determine NULL value support

Syntax

SET NULL ON | OFF

See Also

ALTER TABLE, COALESCE(), CREATE TABLE, EMPTY(), INSERT, ISBLANK(), ISNULL(), NVL(), SET NULLDISPLAY

Description

The SET NULL ON | OFF command is used to determine whether columns in a table support NULL values. With SET NULL ON, table columns will support NULL values by default. INSERT will insert a NULL into any column that does not have a value specified. With SET NULL off, NULL values are not supported by default. This default can be overridden by specifying the NULL or NOT NULL column constraint on an individual column.

Example

set null on
CREATE TABLE nullon (firstname c(20), lastname c(20))
INSERT INTO nullon (lastname) VALUES ("Smith")
? [SET NULL ON]
? [ISNULL() ], isnull(firstname)
? [EMPTY() ], empty(firstname)
wait
SET NULL ON
ISNULL()  .T.
EMPTY()  .F.
Press any key to continue...
 
set null off
CREATE TABLE nulloff (firstname c(20), lastname c(20))
INSERT INTO nulloff (lastname) VALUES ("Smith")
? [SET NULL OFF]
? [ISNULL() ], isnull(firstname)
? [EMPTY() ], empty(firstname)
wait
SET NULL OFF
ISNULL()  .F.
EMPTY()  .T.
Press any key to continue...
 
 
set null off
CREATE TABLE nulloff2 (firstname c(20) NULL, lastname c(20))
INSERT INTO nulloff2 (firstname,lastname) VALUES (NULL,"Smith")
? [SET NULL OFF, NULL Column Constraint]
? [ISNULL() ], isnull(firstname)
? [EMPTY() ], empty(firstname)
wait
SET NULL OFF, NULL Column Constraint
ISNULL()  .T.
EMPTY()  .F.
Press any key to continue...