how to select all columns in sql code example

Example 1: get all columns from table sql

/* To retreive the column names of table using sql */

SELECT COLUMN_NAME.
FROM INFORMATION_SCHEMA. COLUMNS.
WHERE TABLE_NAME = 'Your Table Name'

Example 2: sql all columns

-- MySQL
SELECT * 
FROM INFORMATION_SCHEMA.COLUMNS;

-- SQL Server (possible solution)
SELECT * 
FROM SYS.COLUMNS;

-- Oracle
SELECT * 
FROM ALL_TAB_COLS; -- (If you only want user-defined columns)
-- ALL_TAB_COLS : only user-defined columns
-- ALL_TAB_COLUMNS : both user-defined AND system columns

Tags:

Sql Example