Re: User defined table is not present in postgresql.

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: "MAJUMDER, SAYAN" <sayan(dot)a(dot)majumder(at)capgemini(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: User defined table is not present in postgresql.
Date: 2017-03-28 16:19:53
Message-ID: CAOR=d=01JE1Tc5jzbx2pMMvNuzwrDapG3Fh0oSJoGcXyednveg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tue, Mar 28, 2017 at 3:35 AM, MAJUMDER, SAYAN
<sayan(dot)a(dot)majumder(at)capgemini(dot)com> wrote:
> Hi,
>
> I am new to postgres and presently migrating from sql server to postgres and
> facing some problems. Kindly help me with this.
>
> We have user defined table in sql server, I am unable to find the same in
> postgres. Postgres have the concept of Types but
>
> The problem is I cannot set the default value of a column in Types available
> in postgres. I will be highly obliged if you solve me through
>
> This.

OK You can define custom types with create type.

You can set a default when you create a table.

Types, by definition, do not include a default value though.

postgres=# create type mytype as (a int, b text);
CREATE TYPE
postgres=# create table mytable (a mytype default (0,'abc'));
CREATE TABLE
postgres=# insert into mytable (a) values (default);
INSERT 0 1
postgres=# select * from mytable;
a
---------
(0,abc)

How's that?

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2017-03-28 16:27:36 Re: User defined table is not present in postgresql.
Previous Message John Scalia 2017-03-28 15:52:13 Re: [ADMIN] Replication mode Master-Slave - maintenance question.