// 오류 참조

PostgreSQL 오류 코드

PostgreSQL이 낼 수 있는 모든 SQLSTATE 코드를 공식 부록처럼 클래스별로 묶었습니다. 실제로 자주 만나게 되는 코드는 전체 페이지를 가집니다: 오류가 무슨 뜻인지, 왜 생기는지, 어떻게 고치는지.

PostgreSQL 오류 읽기

PostgreSQL은 모든 오류를 다섯 자리 SQLSTATE 코드로 식별합니다. 처음 두 자리는 클래스입니다: 23 무결성 제약 조건 위반이고, 42 구문 오류 또는 접근 규칙 위반이고, 40 트랜잭션 롤백 등입니다. 다음으로 끝나는 코드는 000 해당 클래스의 일반 코드입니다.

psql 오류 코드가 아니라 메시지를 보여 줍니다. 다음을 실행하세요 \set VERBOSITY verbose SQLSTATE를 확인하거나 드라이버에서 직접 읽으세요: SQLSTATE JDBC와 ODBC에서는, e.pgcode psycopg2에서는, e.sqlstate psycopg 3에서는, err.code node-postgres에서는.

PL/pgSQL에서는 조건 이름으로 오류를 잡을 수 있습니다 (EXCEPTION WHEN unique_violation THEN) 또는 코드(WHEN SQLSTATE '23505' THEN).

이 참조의 모든 PostgreSQL 오류

262개의 코드가 있으며, 63개는 전체 설명(링크 포함)이 있습니다. 코드와 메시지는 PostgreSQL 문서 부록 A: PostgreSQL 오류 코드.

성공적인 완료

코드의미
00000 successful_completion

경고

코드의미
01000 warning
0100C dynamic_result_sets_returned
01008 implicit_zero_bit_padding
01003 null_value_eliminated_in_set_function
01007 privilege_not_granted
01006 privilege_not_revoked
01004 string_data_right_truncation
01P01 deprecated_feature

데이터 없음 (SQL 표준에 따른 경고 클래스이기도 함)

코드의미
02000 no_data
02001 no_additional_dynamic_result_sets_returned

SQL 문이 아직 완료되지 않음

코드의미
03000 sql_statement_not_yet_complete

연결 예외

코드의미
08000 connection_exception
08003 connection_does_not_exist
08006 연결 실패 connection_failure 서버가 연결을 예기치 않게 닫았습니다. 요청을 처리하기 전이나 처리 중에 서버가 비정상 종료됐다는 뜻일 가능성이 높습니다.
08001 연결을 설정할 수 없음 sqlclient_unable_to_establish_sqlconnection "db.example.com" (10.0.0.5) 서버, 포트 5432로의 연결이 실패했습니다: 연결이 거부되었습니다 서버가 그 호스트에서 실행 중이고 TCP/IP 연결을 받고 있습니까?
08004 sqlserver_rejected_establishment_of_sqlconnection
08007 transaction_resolution_unknown
08P01 protocol_violation

트리거된 작업 예외

코드의미
09000 triggered_action_exception

지원되지 않는 기능

코드의미
0A000 지원되지 않는 기능 feature_not_supported 교차 데이터베이스 참조가 구현되지 않았습니다: "otherdb.public.orders"

잘못된 트랜잭션 시작

코드의미
0B000 invalid_transaction_initiation

로케이터 예외

코드의미
0F000 locator_exception
0F001 invalid_locator_specification

잘못된 권한 부여자

코드의미
0L000 invalid_grantor
0LP01 잘못된 권한 부여 작업 invalid_grant_operation 권한 부여 옵션은 역할에게만 부여할 수 있습니다

잘못된 역할 지정

코드의미
0P000 invalid_role_specification

진단 예외

코드의미
0Z000 diagnostics_exception
0Z002 stacked_diagnostics_accessed_without_active_handler

XQuery 오류

코드의미
10608 invalid_argument_for_xquery

CASE 문에서 일치하는 항목을 찾을 수 없음

코드의미
20000 case_not_found

카디널리티 위반

코드의미
21000 서브쿼리에서 여러 행이 반환되었습니다 cardinality_violation 표현식으로 사용된 서브쿼리에서 여러 행이 반환되었습니다

데이터 예외

코드의미
22000 data_exception
2202E array_subscript_error
22021 인코딩에 대한 잘못된 바이트 시퀀스 character_not_in_repertoire 인코딩 "UTF8"에 대한 잘못된 바이트 시퀀스: 0xff
22008 날짜/시간 필드 값이 범위를 벗어났습니다 datetime_field_overflow 날짜/시간 필드 값이 범위를 벗어났습니다: "2026-13-01"
22012 0으로 나눔 division_by_zero 0으로 나눔
22005 error_in_assignment
2200B escape_character_conflict
22022 indicator_overflow
22015 interval_field_overflow
2201E invalid_argument_for_logarithm
22014 invalid_argument_for_ntile_function
22016 invalid_argument_for_nth_value_function
2201F invalid_argument_for_power_function
2201G invalid_argument_for_width_bucket_function
22018 invalid_character_value_for_cast
22007 잘못된 날짜/시간 형식 invalid_datetime_format timestamp 타입에 대한 잘못된 입력 구문: "31/12/2026 25:00"
22019 invalid_escape_character
2200D invalid_escape_octet
22025 invalid_escape_sequence
22P06 nonstandard_use_of_escape_character
22010 invalid_indicator_parameter_value
22023 잘못된 매개변수 값 invalid_parameter_value 매개변수 "TimeZone"에 대한 잘못된 값: "Mars/Olympus"
22013 invalid_preceding_or_following_size
2201B invalid_regular_expression
2201W invalid_row_count_in_limit_clause
2201X invalid_row_count_in_result_offset_clause
2202H invalid_tablesample_argument
2202G invalid_tablesample_repeat
22009 invalid_time_zone_displacement_value
2200C invalid_use_of_escape_character
2200G most_specific_type_mismatch
22004 null_value_not_allowed
22002 null_value_no_indicator_parameter
22003 숫자 값이 범위를 벗어났습니다 numeric_value_out_of_range 정수가 범위를 벗어났습니다
2200H sequence_generator_limit_exceeded
22026 string_data_length_mismatch
22001 타입에 비해 값이 너무 깁니다 string_data_right_truncation 타입 character varying(20)에 비해 값이 너무 깁니다
22011 substring_error
22027 trim_error
22024 unterminated_c_string
2200F zero_length_character_string
22P01 floating_point_exception
22P02 다음 타입에 대한 잘못된 입력 구문 invalid_text_representation 정수 타입에 대한 잘못된 입력 구문: "abc"
22P03 invalid_binary_representation
22P04 bad_copy_file_format
22P05 untranslatable_character
2200L not_an_xml_document
2200M invalid_xml_document
2200N invalid_xml_content
2200S invalid_xml_comment
2200T invalid_xml_processing_instruction
22030 duplicate_json_object_key_value
22031 invalid_argument_for_sql_json_datetime_function
22032 invalid_json_text
22033 invalid_sql_json_subscript
22034 more_than_one_sql_json_item
22035 no_sql_json_item
22036 non_numeric_sql_json_item
22037 non_unique_keys_in_a_json_object
22038 singleton_sql_json_item_required
22039 sql_json_array_not_found
2203A sql_json_member_not_found
2203B sql_json_number_not_found
2203C sql_json_object_not_found
2203D too_many_json_array_elements
2203E too_many_json_object_members
2203F sql_json_scalar_required
2203G sql_json_item_cannot_be_cast_to_target_type

무결성 제약 조건 위반

코드의미
23000 integrity_constraint_violation
23001 restrict_violation
23502 null 값이 not-null 제약 조건을 위반합니다 not_null_violation 관계 "users"의 열 "email"에서 null 값이 not-null 제약 조건을 위반합니다. 상세: 실패한 행은 (7, Ada, null)을 포함합니다.
23503 외래 키 제약 조건 위반 foreign_key_violation 테이블 "orders"에 대한 삽입 또는 업데이트가 외래 키 제약 조건 "orders_customer_id_fkey"를 위반합니다. 상세: 키 (customer_id)=(42)가 테이블 "customers"에 존재하지 않습니다.
23505 중복 키가 고유 제약 조건을 위반합니다 unique_violation 중복 키 값이 고유 제약 조건 "users_email_key"를 위반합니다. 상세: 키 (email)=([email protected])가 이미 존재합니다.
23514 CHECK 제약 조건 위반 check_violation 관계 "orders"에 대한 새 행이 체크 제약조건 "orders_qty_check"를 위반함 세부 정보: 실패한 행은 (12, -1)을 포함합니다.
23P01 배타적 제약 조건 위반 exclusion_violation 충돌하는 키 값이 배타 제약 조건 "bookings_room_during_excl"을 위반했습니다 DETAIL: 키 (room_id, during)=(4, ["2026-05-01 10:00:00","2026-05-01 11:00:00"))가 기존 키 (room_id, during)=(4, ["2026-05-01 10:30:00","2026-05-01 12:00:00"))와 충돌합니다.

잘못된 커서 상태

코드의미
24000 invalid_cursor_state

잘못된 트랜잭션 상태

코드의미
25000 invalid_transaction_state
25001 트랜잭션 블록 내에서 실행할 수 없음 active_sql_transaction CREATE INDEX CONCURRENTLY는 트랜잭션 블록 내에서 실행할 수 없음
25002 branch_transaction_already_active
25008 held_cursor_requires_same_isolation_level
25003 inappropriate_access_mode_for_branch_transaction
25004 inappropriate_isolation_level_for_branch_transaction
25005 no_active_sql_transaction_for_branch_transaction
25006 읽기 전용 SQL 트랜잭션 read_only_sql_transaction 읽기 전용 트랜잭션에서는 INSERT를 실행할 수 없음
25007 schema_and_data_statement_mixing_not_supported
25P01 no_active_sql_transaction
25P02 현재 트랜잭션이 중단됨 in_failed_sql_transaction 현재 트랜잭션이 중단되었으며, 트랜잭션 블록이 끝날 때까지 명령이 무시됩니다
25P03 트랜잭션 중 유휴 세션 시간 초과 idle_in_transaction_session_timeout 트랜잭션 중 유휴 시간 초과로 인해 연결이 종료됩니다
25P04 transaction_timeout

잘못된 SQL 문 이름

코드의미
26000 invalid_sql_statement_name

트리거된 데이터 변경 위반

코드의미
27000 triggered_data_change_violation

잘못된 인가 지정

코드의미
28000 잘못된 인증 규격 invalid_authorization_specification 호스트 "10.0.0.5", 사용자 "app", 데이터베이스 "shop"에 대한 pg_hba.conf 항목 없음, 암호화 없음
28P01 비밀번호 인증 실패 invalid_password 사용자 "app"의 비밀번호 인증 실패

종속 권한 설명자가 여전히 존재함

코드의미
2B000 dependent_privilege_descriptors_still_exist
2BP01 종속 객체가 아직 존재함 dependent_objects_still_exist 다른 객체가 의존하고 있어 customers 테이블을 삭제할 수 없습니다 상세: orders 테이블의 제약 조건 orders_customer_id_fkey가 customers 테이블에 의존합니다 힌트: 의존 객체들도 함께 삭제하려면 DROP ... CASCADE를 사용하세요.

잘못된 트랜잭션 종료

코드의미
2D000 잘못된 트랜잭션 종료 invalid_transaction_termination 잘못된 트랜잭션 종료

SQL 루틴 예외

코드의미
2F000 sql_routine_exception
2F005 function_executed_no_return_statement
2F002 modifying_sql_data_not_permitted
2F003 prohibited_sql_statement_attempted
2F004 reading_sql_data_not_permitted

잘못된 커서 이름

코드의미
34000 invalid_cursor_name

외부 루틴 예외

코드의미
38000 external_routine_exception
38001 containing_sql_not_permitted
38002 modifying_sql_data_not_permitted
38003 prohibited_sql_statement_attempted
38004 reading_sql_data_not_permitted

외부 루틴 호출 예외

코드의미
39000 external_routine_invocation_exception
39001 invalid_sqlstate_returned
39004 null_value_not_allowed
39P01 trigger_protocol_violated
39P02 srf_protocol_violated
39P03 event_trigger_protocol_violated

세이브포인트 예외

코드의미
3B000 savepoint_exception
3B001 잘못된 세이브포인트 지정 invalid_savepoint_specification "before_update" 세이브포인트가 존재하지 않습니다

잘못된 카탈로그 이름

코드의미
3D000 데이터베이스가 존재하지 않습니다 invalid_catalog_name "shop" 데이터베이스가 존재하지 않습니다

잘못된 스키마 이름

코드의미
3F000 스키마가 존재하지 않습니다 invalid_schema_name "sales" 스키마가 존재하지 않습니다

트랜잭션 롤백

코드의미
40000 transaction_rollback
40002 transaction_integrity_constraint_violation
40001 접근을 직렬화할 수 없습니다 serialization_failure 동시 업데이트로 인해 접근을 직렬화할 수 없습니다
40003 statement_completion_unknown
40P01 교착 상태가 감지되었습니다 deadlock_detected 교착 상태 감지됨 DETAIL: 프로세스 1234가 트랜잭션 5678에 대한 ShareLock을 기다리는 중; 프로세스 4321에 의해 차단됨. 프로세스 4321이 트랜잭션 8765에 대한 ShareLock을 기다리는 중; 프로세스 1234에 의해 차단됨.

구문 오류 또는 접근 규칙 위반

코드의미
42000 syntax_error_or_access_rule_violation
42601 다음 근처에서 구문 오류 syntax_error "FROM" 근처에서 구문 오류 LINE 1: SELECT id, name, FROM users; ^
42501 권한이 거부되었습니다 insufficient_privilege 테이블 orders에 대한 권한이 거부되었습니다
42846 강제 변환 불가 cannot_coerce 정수 타입을 uuid로 캐스트할 수 없음
42803 열은 GROUP BY 절에 나타나야 함 grouping_error 열 "o.customer_id"는 GROUP BY 절에 있거나 집계 함수에 쓰여야 합니다
42P20 windowing_error
42P19 invalid_recursion
42830 잘못된 외래 키 invalid_foreign_key 참조된 테이블 "customers"에 대해 주어진 키와 일치하는 고유 제약 조건이 없습니다.
42602 invalid_name
42622 name_too_long
42939 reserved_name
42804 데이터 타입 불일치 datatype_mismatch 열 "created_at"의 타입은 timestamp with time zone인데 표현식은 integer입니다. 힌트: 표현식을 다시 쓰거나 형변환하세요.
42P18 파라미터의 데이터 타입을 결정할 수 없습니다. indeterminate_datatype 매개변수 $1의 데이터 유형을 판별할 수 없습니다
42P21 collation_mismatch
42P22 indeterminate_collation
42809 wrong_object_type
428C9 generated_always
42703 열이 존재하지 않음 undefined_column 열 "emial"이(가) 존재하지 않습니다. LINE 1: SELECT emial FROM users; ^ 힌트: 아마 "users.email" 열을 참조하려던 것이 아닐까요?
42883 함수가 존재하지 않습니다. undefined_function 함수 lower(integer)가 존재하지 않습니다 LINE 1: SELECT lower(42); ^ 힌트: 주어진 이름과 인수 타입에 일치하는 함수가 없습니다. 명시적 타입 캐스트를 추가해야 할 수도 있습니다.
42P01 관계가 존재하지 않습니다 undefined_table 관계 "orders"가 존재하지 않습니다 LINE 1: SELECT * FROM orders; ^
42P02 매개변수가 없습니다 undefined_parameter 매개변수 $1이 없습니다
42704 정의되지 않은 객체 undefined_object "jsonbb" 타입이 존재하지 않습니다
42701 duplicate_column
42P03 duplicate_cursor
42P04 데이터베이스가 이미 존재합니다 duplicate_database 데이터베이스 "shop"이(가) 이미 존재합니다
42723 duplicate_function
42P05 duplicate_prepared_statement
42P06 스키마가 이미 존재합니다 duplicate_schema "sales" 스키마가 이미 존재합니다
42P07 관계가 이미 존재합니다 duplicate_table 관계 "orders"가 이미 존재합니다
42712 duplicate_alias
42710 중복 객체 duplicate_object "app" 역할이 이미 존재합니다
42702 열 참조가 모호합니다 ambiguous_column 열 참조 "id"가 모호합니다 LINE 1: SELECT id FROM orders JOIN customers ON customers.id = orders.customer_id; ^
42725 ambiguous_function
42P08 ambiguous_parameter
42P09 ambiguous_alias
42P10 잘못된 열 참조 invalid_column_reference ON CONFLICT 명세와 일치하는 고유 또는 제외 제약 조건이 없습니다
42611 invalid_column_definition
42P11 invalid_cursor_definition
42P12 invalid_database_definition
42P13 invalid_function_definition
42P14 invalid_prepared_statement_definition
42P15 invalid_schema_definition
42P16 invalid_table_definition
42P17 invalid_object_definition

WITH CHECK OPTION 위반

코드의미
44000 with_check_option_violation

리소스 부족

코드의미
53000 insufficient_resources
53100 디스크가 가득 찼습니다 disk_full 파일 "base/16384/16397"을(를) 확장할 수 없습니다: 장치에 남은 공간이 없습니다 HINT: 디스크 여유 공간을 확인하세요.
53200 메모리 부족 out_of_memory 메모리 부족 DETAIL: 메모리 컨텍스트 "ExecutorState"에서 1048576 크기의 요청 처리 실패.
53300 연결이 너무 많습니다 too_many_connections 죄송합니다, 이미 클라이언트가 너무 많습니다
53400 configuration_limit_exceeded

프로그램 한도 초과

코드의미
54000 프로그램 한도 초과 program_limit_exceeded 인덱스 "documents_body_idx"의 인덱스 행 크기 3200이 btree 버전 4 최대치인 2704를 초과합니다 DETAIL: 인덱스 행이 관계 "documents"의 튜플 (12,3)을 참조합니다 HINT: 버퍼 페이지의 1/3보다 큰 값은 인덱싱할 수 없습니다. 값의 MD5 해시로 함수 인덱스를 만들거나 전체 텍스트 인덱싱을 고려하세요.
54001 statement_too_complex
54011 too_many_columns
54023 too_many_arguments

객체가 필요한 상태에 있지 않음

코드의미
55000 객체가 필요한 상태에 있지 않음 object_not_in_prerequisite_state 시퀀스 "orders_id_seq"의 currval이 이 세션에서 아직 정의되지 않음
55006 객체 사용 중 object_in_use 데이터베이스 "shop"에 다른 사용자가 접근하는 중입니다. 상세: 다른 세션 1개가 이 데이터베이스를 사용하고 있습니다.
55P02 cant_change_runtime_param
55P03 잠금 사용 불가 lock_not_available 관계 "orders"의 행에 대한 잠금을 얻을 수 없습니다
55P04 unsafe_new_enum_value_usage

작업자 개입 필요

코드의미
57000 operator_intervention
57014 명령 취소 중 query_canceled 명령 시간 초과로 인해 명령 취소 중
57P01 관리자 때문에 연결 종료 중 admin_shutdown 관리자 명령 때문에 연결 종료 중
57P02 crash_shutdown
57P03 지금 연결할 수 없음 cannot_connect_now 데이터베이스 시스템이 시작 중입니다
57P04 database_dropped
57P05 idle_session_timeout

시스템 오류 (PostgreSQL 자체 외부의 오류)

코드의미
58000 system_error
58030 io_error
58P01 정의되지 않은 파일 undefined_file 파일 "/tmp/orders.csv"을(를) 읽기용으로 열 수 없습니다: 그런 파일이나 디렉터리가 없습니다
58P02 duplicate_file
58P03 file_name_too_long

설정 파일 오류

코드의미
F0000 config_file_error
F0001 lock_file_exists

외부 데이터 래퍼 오류(SQL/MED)

코드의미
HV000 fdw_error
HV005 fdw_column_name_not_found
HV002 fdw_dynamic_parameter_value_needed
HV010 fdw_function_sequence_error
HV021 fdw_inconsistent_descriptor_information
HV024 fdw_invalid_attribute_value
HV007 fdw_invalid_column_name
HV008 fdw_invalid_column_number
HV004 fdw_invalid_data_type
HV006 fdw_invalid_data_type_descriptors
HV091 fdw_invalid_descriptor_field_identifier
HV00B fdw_invalid_handle
HV00C fdw_invalid_option_index
HV00D fdw_invalid_option_name
HV090 fdw_invalid_string_length_or_buffer_length
HV00A fdw_invalid_string_format
HV009 fdw_invalid_use_of_null_pointer
HV014 fdw_too_many_handles
HV001 fdw_out_of_memory
HV00P fdw_no_schemas
HV00J fdw_option_name_not_found
HV00K fdw_reply_handle
HV00Q fdw_schema_not_found
HV00R fdw_table_not_found
HV00L fdw_unable_to_create_execution
HV00M fdw_unable_to_create_reply
HV00N fdw_unable_to_establish_connection

PL/pgSQL 오류

코드의미
P0000 plpgsql_error
P0001 예외 발생 raise_exception 계좌 42의 잔고가 부족합니다
P0002 no_data_found
P0003 too_many_rows
P0004 assert_failure

내부 오류

코드의미
XX000 내부 오류 internal_error 관계 16397에 대한 캐시 조회 실패
XX001 데이터 손상 data_corrupted 관계 base/16384/16397의 블록 1234에서 잘못된 페이지
XX002 index_corrupted
// 하나의 클라이언트, 모든 엔진

PostgreSQL과 더 빠르게 작업하는 방법

SQLly는 macOS, Windows, Linux용 네이티브 SQL 클라이언트로, 스키마 인식 IntelliSense와 위험한 명령문에 대한 안전장치를 갖추고 있습니다.