Home » SQL & PL/SQL » SQL & PL/SQL » Create table with date constraint
Create table with date constraint [message #23474] Wed, 11 December 2002 15:13 Go to next message
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 Go to previous messageGo to next message
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.
Re: Create table with date constraint [message #23489 is a reply to message #23474] Thu, 12 December 2002 12:18 Go to previous message
HG
Messages: 13
Registered: December 2002
Junior Member
Excuse me, i hade problems on my mind. and still have them.
Previous Topic: subquery
Next Topic: How can I see the object which is using some other object?
Goto Forum:
  


Current Time: Wed May 15 16:46:56 CDT 2024