
PostgreSQLでテーブルの作成と削除を行います。
テーブルを作成する!
authenticationというテーブルを作成します。
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テーブルを削除します。
inventory=# drop table authentication; DROP TABLE inventory=# \dt Did not find any relations.
おわりに
PostgreSQLでテーブルの作成と削除は、「create table」、「drop table」コマンドで行います。
参考情報
関連記事
参考書籍(Amazon)
