0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PgAdminでPostgreSQLを操作するために知っておきたいこと

Posted at

PostgreSQLでは大文字と小文字を区別する

データベース名、カラム名は大文字と小文字を区別します。

たとえば次のSQLを使った場合、

SELECT Name FROM Users WHERE Id = 1

実際は次のクエリを実行したことになります。

SELECT name FROM users WHERE id = 1

もし、大文字でUSERSを定義している場合、結果は実行エラーになります。

大文字と小文字を区別したい場合はダブルクオーテーションを使います。

SELECT "Name" FROM "Users" WHERE "Id" = 1

検索条件が文字列や日付の場合にはシングルクオーテーションを使います。

SELECT "Name" FROM "Users" WHERE "Name" = 'Taro'
SELECT "Name" FROM "Users" WHERE "CreateDate" > '2024-12-03'

ダブルクオーテーションを使うと列名と判断され、実行エラーになります。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?