{{htmlmetatags> metatag-description=(테이블 정보, 컬럼 정보, Table, Column, 데이터베이스, DBMS, SQL, MySQL, MariaDB, MSSQL, Oracle, Tibero, PostgreSQL) metatag-og:description=(테이블 정보, 컬럼 정보, Table, Column, 데이터베이스, DBMS, SQL, MySQL, MariaDB, MSSQL, Oracle, Tibero, PostgreSQL) }} ====== 테이블/컬럼 정보 ====== 최소 지원 버전은 약간의 차이가 있을 수 있습니다. ===== MySQL/MariaDB ===== /* MySQL 5.0.1 이상/MariaDB 5.1 이상 */ -- 테이블 정보 SELECT * FROM information_schema.tables WHERE table_schema = '{데이터베이스}' ORDER BY table_name ASC ; -- 컬럼 정보 SELECT * FROM information_schema.columns WHERE table_schema = '{데이터베이스}' AND table_name = '{테이블}' ORDER BY ordinal_position ASC ; ===== MSSQL ===== /* MSSQL 2005 이상 */ -- 테이블 정보 SELECT * FROM sys.tables ORDER BY name ASC ; -- 컬럼 정보 SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('{테이블}') ORDER BY column_id ASC ; ===== Oracle/Tibero ===== /* Oracle 8i 이상/Tibero 4 이상 */ -- 테이블 정보 SELECT * FROM all_tables ORDER BY table_name ASC ; -- 컬럼 정보 SELECT * FROM all_tab_columns WHERE table_name = '{테이블}' ORDER BY column_id ASC ; ===== PostgreSQL ===== /* PostgreSQL 7.4 이상 */ -- 테이블 정보 SELECT * FROM information_schema.tables WHERE table_catalog = '{데이터베이스}' AND table_schema = 'public' ORDER BY table_name ASC ; -- 컬럼 정보 SELECT * FROM information_schema.columns WHERE table_catalog = '{데이터베이스}' AND table_name = '{테이블}' AND table_schema = 'public' ORDER BY ordinal_position ASC ; {{tag>"쿼리" "Query" "기본"}}