Table 「sample1.sample」 カラムの追加
testdb=# \d sample
Table "sample1.sample"
Column | Type | Collation | Nullable | Default
-----------+---------+-----------+----------+---------
id | integer | | |
name | text | | |
address | text | | |
groupname | text | | |
testdb=# ALTER TABLE sample ADD COLUMN memo text;
ALTER TABLE
testdb=# \d sample
Table "sample1.sample"
Column | Type | Collation | Nullable | Default
-----------+---------+-----------+----------+---------
id | integer | | |
name | text | | |
address | text | | |
groupname | text | | |
memo | text | | |
testdb=# testdb=# ALTER TABLE sample ADD UNIQUE(name);
ALTER TABLE
testdb=# testdb-# Table "sample1.sample"
Column | Type | Collation | Nullable | Default
-----------+---------+-----------+----------+---------
id | integer | | |
name | text | | |
address | text | | |
groupname | text | | |
memo | text | | |
Indexes:
"sample_name_key" UNIQUE CONSTRAINT, btree (name)
testdb=# ALTER TABLE sample ALTER COLUMN groupname SET DEFAULT '営業';
ALTER TABLE
testdb=# \d sample
Table "ssample1.sample"
Column | Type | Collation | Nullable | Default
-----------+---------+-----------+----------+--------------
id | integer | | |
name | text | | |
address | text | | |
groupname | text | | | '営業'::text
memo | text | | |
Indexes:
"sample_name_key" UNIQUE CONSTRAINT, btree (name)
この記事が気に入ったらサポートをしてみませんか?