Q
Problem solve Get help with specific problems with your technologies, process and projects.

Does the lack of domains hurt SQL?

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


This was last published in May 2001

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close