Does the lack of domains hurt SQL?
Great question. My answer is "No."
Domains were introduced into the standard (it says here in the SQL book that I'm reading) with SQL-92. So in one sense, SQL hasn't been lacking in domains for many years. However, to be practical, domains are only useful if the database you are using supports them.
Here's an example --
create domain astooge varchar(9) not null default 'curly' check ( value in ('curly','larry','moe' ,'shemp','curly joe','joe') )
From what I can tell, the only advantage that a domain has over defining an ordinary check constraint is that you do not have to repeat any of the clauses (e.g. datatype, nullity, default, check), which get carried over to every column that is defined on the domain.
create table stoogesoundbite ( title varchar(100) , stooge astooge ) insert into stoogesoundbite (title) values ('nyuk nyuk nyuk')
For More Information
- What do you think about this answer? E-mail us at editor@searchDatabase.com with your feedback.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- The Best SQL Web Links
- Have a SQL tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
- Ask your technical SQL questions--or help out your peers by answering them--in our live discussion forums.
- Ask the Experts yourself: Our SQL guru is waiting to answer your technical questions.
Dig Deeper on Oracle and SQL
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.