
PostgreSQLでテーブルの作成と削除を行います。
テーブルを作成する!
authenticationというテーブルを作成します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | inventory=# create table authentication ( user_id VARCHAR ( 50 ) PRIMARY KEY, username VARCHAR ( 50 ) UNIQUE NOT NULL, password VARCHAR ( 50 ) NOT NULL, email VARCHAR ( 255 ) UNIQUE NOT NULL, created_on TIMESTAMP NOT NULL, last_login TIMESTAMP ); CREATE TABLE inventory=# \dt List of relations Schema | Name | Type | Owner --------+----------------+-------+---------- public | authentication | table | postgres (1 row) |
テーブルを削除する!
作成したauthenticationテーブルを削除します。
1 2 3 4 | inventory=# drop table authentication; DROP TABLE inventory=# \dt Did not find any relations. |
おわりに
PostgreSQLでテーブルの作成と削除は、「create table」、「drop table」コマンドで行います。
参考情報
関連記事
参考書籍(Amazon)