DBAtlas · 데이터베이스 운영 아틀라스

테이블 컬럼 / 구조 조회(describe)

Oracle

SELECT column_name, data_type, data_length, nullable
FROM user_tab_columns
WHERE table_name = 'EMPLOYEE'
ORDER BY column_id;
-- Shortcut (SQL*Plus): DESC employee

테이블 이름은 대문자로 저장된다(따옴표 없이 생성한 경우).

PostgreSQL

SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name = 'customer'
ORDER BY ordinal_position;
-- psql shortcut: \d customer

\d는 인덱스, 제약 조건, 외래 키도 보여 준다.

MySQL

DESCRIBE customer;
-- or: SHOW COLUMNS FROM customer;

전체 정의는 SHOW CREATE TABLE customer;를 사용한다(아래 'DDL 생성' 항목 참고).

SQL Server

SELECT c.name, t.name AS type, c.max_length, c.is_nullable
FROM sys.columns c
JOIN sys.types t ON c.user_type_id = t.user_type_id
WHERE c.object_id = OBJECT_ID('dbo.customer')
ORDER BY c.column_id;
-- Shortcut: EXEC sp_help 'dbo.customer';

sp_help는 컬럼 외에 인덱스와 제약 조건도 나열한다.

MongoDB

// The schema is flexible; infer it from a sample document:
db.customer.findOne()
// For field coverage: db.customer.aggregate([{ $sample: { size: 100 } }])

MongoDB에는 고정 스키마가 없으며 필드는 문서마다 다를 수 있다. $jsonSchema 검증기가 정의되어 있으면 db.getCollectionInfos로 볼 수 있다.

Redis

TYPE mykey        # string | list | set | hash | zset | stream
OBJECT ENCODING mykey   # internal encoding

고정 스키마가 없으며 각 키의 타입과 인코딩을 개별적으로 조회한다. 해시 필드는 HGETALL을 사용한다.

DBAtlas에서 열기 →