Ask Your Question
0

SQL does not create default value [closed]

asked 2014-01-27 21:32:31 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

SQL does not create a default value

Hi, Neither of these SQL commands (entered with tools/SQL, then checked by view/refesh , right click tablename / edit) sets a default value. What is wrong?

<<<test1>>></test1>

CREATE CACHED TABLE TESTC4

( ID1 INT GENERATED BY DEFAULT AS IDENTITY,

  TC1 INT DEFAULT 3,

  TC2 VARCHAR(10) DEFAULT 'THREE',

  TC3 INT

);

<<<test2>>></test2>

ALTER TABLE TESTC6

ADD TC7 VARCHAR(10)

DEFAULT 'STUFF';

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-19 04:15:40.532932

1 Answer

Sort by » oldest newest most voted
0

answered 2014-01-28 00:10:18 +0200

w_whalley gravatar image

It comes from bypassing the GUI when you define the table. If you look at your database using an archive manager (you can see the table definition in the database/script file) you will find that the defaults are recorded in the table definition. If you add records to the table the defaults are used.

But the defaults appear blank if you edit the table using the base GUI. If you add a different default in the GUI then it will be used while the database is open but when it is closed and reopened the original default will be used. You can use an archive manager to edit the default in the database/script file or by an ALTER TABLE command in the SQL tool.

edit flag offensive delete link more

Comments

Thank you for your answer.

So, the GUI saves a default "in the data" but direct SQL commands save a default "in the table definition". The table GUI editor looks only at "the data" default and not the separate "table definition" default.

What can I use as "an archive manager" to see the "table definition" since the GUI does not show it? Note: view/refresh tables (even after a save) does not seem to make an SQL default appear in the table GUI editor. Do do both types behave functionally the same?

How do these 2 methods compare to the default from the comboBox of a form?

This issue is mentioned in: Creating Tables. page 41 of BH40-BaseHandbook as follows:

Default values: The term "Default value" in the GUI does not mean what the database user generally understands as a default value. The GUI displays a certain value visibly, which ...(more)

dw271828 gravatar imagedw271828 ( 2014-01-28 06:56:53 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2014-01-27 21:32:31 +0200

Seen: 257 times

Last updated: Jan 28 '14