LoginSignup
4
3

More than 5 years have passed since last update.

PostgreSQLでテーブルを作成する際に指定できないテーブル名について

Last updated at Posted at 2017-08-20

PostgreSQLを使ってデータベースを作成する際に以下のように設定しようとしたところ、構文エラーが発生しました。

PostgreSQL
create table user (
id text primary key,
pass text not null
);

スペルミスをしている様子もなく、原因が分からずあれこれ探していたところ、テーブル名として、userは使用できないようです。

PostgreSQLではその他にもテーブル名として使用できないものがいくつかあるようなので、調べておく必要があるかもしれませんね。
(そもそも、テーブル名にsをつける癖を身に付けるほうが先か・・。)

参考サイト
stackoverflow: Cannot create a database table named 'user' in PostgreSQL
https://stackoverflow.com/questions/22256124/cannot-create-a-database-table-named-user-in-postgresql

PostgreSQL: Appendix C. SQL Key Words
https://www.postgresql.org/docs/9.3/static/sql-keywords-appendix.html

4
3
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
4
3