Create table with date constraint [message #23474] |
Wed, 11 December 2002 15:13 |
HG
Messages: 13 Registered: December 2002
|
Junior Member |
|
|
Hello (again),
I'm not an experienced SQL programmer, but i'm working on a SQLPlus database. During the ceation of a table i would like a constraint for a date-field (dd/mm/yyyy) and already a default value (current date like '12/12/2002'). Also in this database is a phone number i need to check the position of the '/', it can appear in 3th, 4th or 5th position (99/9999999 or 999/999999 or 9999/999999) this must also be done during the creation of the table. I cannot use triggers in the events.
Thanks in advance
HG.
|
|
|
Re: Create table with date constraint [message #23475 is a reply to message #23474] |
Wed, 11 December 2002 15:51 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
I have the same question as when you previously posted this question. What do you mean by a constraint on the date? If it is a DATE datatype, you will only be able to enter date values.
The default value can be handled by:
create table t (x int, d date default sysdate); -- or trunc(sysdate) if you do not want the time component
You will not be able to enforce the '/' validation without a trigger. This is what they are designed to handle. If you, for some strange/unfounded reason, choose not to use triggers - you should have mentioned that in your first post so no one wasted time showing you how to meet your requirement.
|
|
|
|