O$: Null Fields
CLIFFORD ILKAY
clifford_ilkay at dinamis.com
Tue Apr 21 13:52:40 EDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Christine Penner wrote:
> We use Postgres.
Use the Force, Christine. :) If you want to avoid NULLs, why not set
default values for those columns in which you don't want NULLs? The
following illustrates.
christine=# create table test (id serial primary key, foo varchar not
null default 'BLUB', bar integer default 0);
NOTICE: CREATE TABLE will create implicit sequence "test_id_seq" for
serial column "test.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"test_pkey" for table "test"
CREATE TABLE
Time: 36.697 ms
christine=# insert into test default values;
INSERT 12523162 1
Time: 13.921 ms
christine=# insert into test (id, foo, bar) values (default, 'Hello',
default);
INSERT 12523163 1
Time: 9.422 ms
christine=# insert into test (id, foo, bar) values (default, default, 99);
INSERT 12523164 1
Time: 5.471 ms
christine=# select * from test;
id | foo | bar
- ----+-------+-----
1 | BLUB | 0
2 | Hello | 0
3 | BLUB | 99
(3 rows)
Time: 0.507 ms
See <http://www.postgresql.org/docs/8.3/interactive/sql-insert.html>.
- --
Regards,
Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada M4N 3P6
<http://dinamis.com>
+1 416-410-3326
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFJ7gfolUaSlL+/juwRAsIWAJ0bxeNn5Xs373DgxbzOOwJBTwLSygCeOGh9
AZxxxwVm1TFAuxR73wvNB6I=
=XNyV
-----END PGP SIGNATURE-----
More information about the omnisdev-en
mailing list