0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PostgreSQL DDL のメモ

Posted at

##PRIMARY KEYの削除

ALTER TABLE table_name DROP CONSTRAINT table_pkey;

##PRIMARY KEYの作成

ALTER TABLE table_name ADD CONSTRAINT table_key PRIMARY KEY(column1,column2);

###PRIMARY KEYのリーネム

ALTER TABLE table_name RENAME CONSTRAINT constraint_name TO new_constraint_name;

###テーブル名変更

ALTER TABLE table_name RENAME TO new_table_name;

###テーブルに VARCHAR 型の列を追加します。

ALTER TABLE table_name ADD COLUMN address VARCHAR(30);

###既存の列名を変更します。

ALTER TABLE table_name RENAME COLUMN address TO city;

###既存の列を削除します。

 ALTER TABLE table_name DROP COLUMN user_type; 

###カラムのデータ型を変更

ALTER TABLE table_name ALTER COLUMN user_type TYPE VARCHAR;

##PostgreSQL 関連参考URL
https://www.postgresqltutorial.com/
https://www.postgresqltutorial.com/postgresql-add-column/

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?