LoginSignup
3
1

More than 3 years have passed since last update.

PostgreSQL: column does not existに出会った。

Last updated at Posted at 2021-03-16

PostgreSQLを使い始めてColomn does not exist っていうエラーに出会ったけど、超初歩的なミスだったためか日本語の記事があまりなかったためメモを残しておきます。
具体的な経緯としてはINSETしようとしてtext型を値に入れたらエラーが出てしまいました。
ERROR: column does not exist
っていうエラーです。

原因

結局の原因としては文字列の値をシングルクオーテーションで囲わず、ダブルクオーテーションで囲んでしまっていたからです。

解決策

値をシングルクオーテーションで囲みましょう。

INSERT INTO TABLE (name varchar) VALUES('test');

こういうことね。

何故 " " これはだめなのか

どうやらpsqlでは""は大文字小文字を区別するためのクオートとして、''は文字列を値として使うためのクオートらしいです。
超初歩的な内容だったため忘れてました。(´・ω・`)

参考文献
https://stackoverflow.com/questions/12428496/cannot-get-simple-postgresql-insert-to-work
(stack overflow)

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