xxxxxxxxxx
sp_columns feeAgreement
-- or
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = N'feeAgreement'
xxxxxxxxxx
/*Get all columns from a table (sql server)*/
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'table name';
xxxxxxxxxx
-- 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
xxxxxxxxxx
import sqlite3
# Connect to the database
connection = sqlite3.connect('your_database.db')
cursor = connection.cursor()
# Replace 'your_table' with the actual table name
table_name = 'your_table'
# Execute a query to retrieve the column names
cursor.execute(f"PRAGMA table_info({table_name})")
# Fetch all rows containing column information
columns = cursor.fetchall()
# Extract the column names (2nd item in each row)
column_names = [column[1] for column in columns]
# Print the column names
for column_name in column_names:
print(column_name)
# Close the database connection
connection.close()
xxxxxxxxxx
-- Works for sqlite
-- All column info in a table and their types
SELECT sql FROM sqlite_master
WHERE name= table_name
xxxxxxxxxx
-- You can select data from a table using a SELECT statement.
-- Select all columns from table:
SELECT *
FROM example_table;