Re: [GENERAL] Default column value [ANSWERED]

2016-12-30 Thread Adrian Klaver
On 12/30/2016 08:51 AM, Rich Shepard wrote: On Fri, 30 Dec 2016, David G. Johnston wrote: "The CHECK clause specifies an expression producing a Boolean result which new or updated rows must satisfy for an insert or update operation to succeed. Expressions evaluating to TRUE or UNKNOWN succeed."

Re: [GENERAL] Default column value

2016-12-30 Thread Joshua D. Drake
On 12/30/2016 06:46 AM, Adrian Klaver wrote: On 12/30/2016 06:38 AM, Rich Shepard wrote: test=> \d default_test Table "public.default_test" Column | Type| Modifiers +---+--- id | integer | fld_1 | character varying | To

Re: [GENERAL] Default column value [ANSWERED]

2016-12-30 Thread Rich Shepard
On Fri, 30 Dec 2016, David G. Johnston wrote: "The CHECK clause specifies an expression producing a Boolean result which new or updated rows must satisfy for an insert or update operation to succeed. Expressions evaluating to TRUE or UNKNOWN succeed." NULL == "UNKNOWN" David, I forgot abou

Re: [GENERAL] Default column value

2016-12-30 Thread David G. Johnston
On Fri, Dec 30, 2016 at 9:19 AM, Rich Shepard wrote: > On Fri, 30 Dec 2016, Adrian Klaver wrote: > > DEFAULT is what is the column is set to if the user does not specify a >> value. As shown above a user can supply a NULL value. To guard against >> that the NOT NULL constraint is required. >> > >

Re: [GENERAL] Default column value

2016-12-30 Thread Rich Shepard
On Fri, 30 Dec 2016, Adrian Klaver wrote: DEFAULT is what is the column is set to if the user does not specify a value. As shown above a user can supply a NULL value. To guard against that the NOT NULL constraint is required. One more case I'd appreciate being clarified: when the column's va

Re: [GENERAL] Default column value

2016-12-30 Thread Rich Shepard
On Fri, 30 Dec 2016, Adrian Klaver wrote: DEFAULT is what is the column is set to if the user does not specify a value. As shown above a user can supply a NULL value. To guard against that the NOT NULL constraint is required. Thanks, Adrian. This was not clear to me when I read the manual.

Re: [GENERAL] Default column value

2016-12-30 Thread Rich Shepard
On Fri, 30 Dec 2016, Tom Lane wrote: No, because you can explicitly insert a null. DEFAULT only controls what happens when you omit the column in an INSERT command. tom, Thanks for clarifying. I did not pick this up from reading the manual and knew that NULL could be an explicitly-defined d

Re: [GENERAL] Default column value

2016-12-30 Thread Adrian Klaver
On 12/30/2016 06:38 AM, Rich Shepard wrote: > Reading the 9.6 docs suggests an answer to my question, but does not > explicitly answer it, so I ask here. > > If a column has a default value specified does this mean the column > cannot > contain a NULL value? In other words, is DEFAULT NOT NUL

Re: [GENERAL] Default column value

2016-12-30 Thread Tom Lane
Rich Shepard writes: >If a column has a default value specified does this mean the column cannot > contain a NULL value? In other words, is DEFAULT NOT NULL > redundant? No, because you can explicitly insert a null. DEFAULT only controls what happens when you omit the column in an INSERT co

Re: [GENERAL] Default column value

2016-12-30 Thread Adrian Klaver
On 12/30/2016 06:38 AM, Rich Shepard wrote: Reading the 9.6 docs suggests an answer to my question, but does not explicitly answer it, so I ask here. If a column has a default value specified does this mean the column cannot contain a NULL value? In other words, is DEFAULT NOT NULL redundan

[GENERAL] Default column value

2016-12-30 Thread Rich Shepard
Reading the 9.6 docs suggests an answer to my question, but does not explicitly answer it, so I ask here. If a column has a default value specified does this mean the column cannot contain a NULL value? In other words, is DEFAULT NOT NULL redundant? TIA, Rich -- Sent via pgsql-general ma

Re: [GENERAL] default column value using a function, trigger, or

2005-05-03 Thread Scott Marlowe
On Tue, 2005-05-03 at 17:31, Roderick A. Anderson wrote: > I am trying to come up with a method to have a default value for a > column based on a function and other columns. I'm hoping ( well not too > much ) that what I figure out here will apply to MS SQL Server as I am > stuck using it unles

[GENERAL] default column value using a function, trigger, or whatever

2005-05-03 Thread Roderick A. Anderson
I am trying to come up with a method to have a default value for a column based on a function and other columns. I'm hoping ( well not too much ) that what I figure out here will apply to MS SQL Server as I am stuck using it unless I can prove there ain't no way it's going to happen. ( Now th