domain feature - details

Поиск
Список
Период
Сортировка
Искать

domain feature - details

От:
al dev <aldevpgsql@yahoo.com>
Дата:
Hi all:
More details on what domains are. Domains are global
column definitions, upon which column definitions
can be based. A domain specifies a data type, and a
set of column attributes and constraints. Subsequent
table definitions can use the domain to define columns.

Here is the detail for 'ALTER DOMAIN' feature. I 
pulled this off the chapter 42 at 
http://sunsite.unc.edu/LDP/HOWTO/Database-HOWTO.html

 ::=
         ALTER DOMAIN  

      ::=
           
         | 
         | 
         | 

      ::= SET 

      ::= DROP DEFAULT

      ::=
         ADD 

      ::=
         DROP CONSTRAINT 

      ::=
         DROP DOMAIN  

And the create domain syntax is as follows:---
 ::=
         CREATE DOMAIN 
             [ AS ] 
           [  ]
           [ ... ]
           [  ]

      ::=
         [  ]
          [  ]

(To search a word in chapter 42, use CTRL+F in browser)
I hope to see this in postgreSQL 6.4

al
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

Re: [HACKERS] domain feature - details

От:
Mattias Kregert <matti@algonet.se>
Дата:
al dev wrote:
> 
> Hi all:
> More details on what domains are. Domains are global
> column definitions, upon which column definitions
> can be based. A domain specifies a data type, and a
> set of column attributes and constraints. Subsequent
> table definitions can use the domain to define columns.
> 
> Here is the detail for 'ALTER DOMAIN' feature. I
> pulled this off the chapter 42 at
> http://sunsite.unc.edu/LDP/HOWTO/Database-HOWTO.html> 
>  ::=
>          ALTER DOMAIN  
> 
>       ::=
>            
>          | 
>          | 
>          | 

What happens if I change a DOMAIN after I have created tables with
it? Does CONSTRAINT's and DEFAULTS and TYPES change for those tables,
or should it only affect tables created after the change?

Suppose I do this:
1. I create DOMAIN for "Person", and create lots of tables with
  Person columns.
2. After some weeks, I want to CONSTRAIN Person to disallow NULL
  social security number, so I change the "Person" DOMAIN.

Do I have to re-create all tables, or will the change take effect
immediately? Will some changes take effect, like default and constraint,
but not the data type? Or will changes in data type cause the tables
to be modified? Will the database lock the tables and convert them
when I type the ALTER command?

/* m */

Re: [HACKERS] domain feature - details

От:
The Hermit Hacker <scrappy@hub.org>
Дата:
On Fri, 6 Mar 1998, Mattias Kregert wrote:

> al dev wrote:
> > 
> > Hi all:
> > More details on what domains are. Domains are global
> > column definitions, upon which column definitions
> > can be based. A domain specifies a data type, and a
> > set of column attributes and constraints. Subsequent
> > table definitions can use the domain to define columns.
> > 
> > Here is the detail for 'ALTER DOMAIN' feature. I
> > pulled this off the chapter 42 at
> > http://sunsite.unc.edu/LDP/HOWTO/Database-HOWTO.html> 
> >  ::=
> >          ALTER DOMAIN  
> > 
> >       ::=
> >            
> >          | 
> >          | 
> >          | 
> 
> What happens if I change a DOMAIN after I have created tables with
> it? Does CONSTRAINT's and DEFAULTS and TYPES change for those tables,
> or should it only affect tables created after the change?
> 
> Suppose I do this:
> 1. I create DOMAIN for "Person", and create lots of tables with
>   Person columns.
> 2. After some weeks, I want to CONSTRAIN Person to disallow NULL
>   social security number, so I change the "Person" DOMAIN.
> 
> Do I have to re-create all tables, or will the change take effect
> immediately? Will some changes take effect, like default and constraint,
> but not the data type? Or will changes in data type cause the tables
> to be modified? Will the database lock the tables and convert them
> when I type the ALTER command?

	If I'm understanding what has been said, then this will affect any
table that uses that domain...same as a 'view' that does a subselect will
change its results based on how the data changes in the subselect..

	In a sense, I sort of see a DOMAIN as being similar to a trigger,
where, upon INSERT, you check the value being entered for a specific range
of values...



FAQ