[Pgsql-ayuda] valores predeterminados en tablas

Alvaro Herrera alvherre@dcc.uchile.cl
Mon, 18 Aug 2003 18:13:36 -0400


On Sat, Aug 16, 2003 at 10:14:40AM -0300, Martin Marques wrote:
> Existe alguna forma de que un campo de una tabla tome un valor por defecto 
> (DEFAULT) sacado de una consulta de SELECT?

Del manual:

"DEFAULT default_expr

    The DEFAULT clause assigns a default data value for the column whose
    column definition it appears within. The value is any variable-free
    expression (subselects and cross-references to other columns in the
    current table are not allowed). The data type of the default
    expression must match the data type of the column.

    The default expression will be used in any insert operation that
    does not specify a value for the column. If there is no default
    for a column, then the default is NULL."

http://www14.us.postgresql.org/docs/7.3/static/sql-createtable.html

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"You knock on that door or the sun will be shining on places inside you
that the sun doesn't usually shine" (en Death: "The High Cost of Living")