Answers for "count number of column in a result table"

4

how to count number of columns in a table in sql server

-- Oracle
SELECT count(*) FROM ALL_TAB_COLUMNS WHERE OWNER='owner_name' 
	AND TABLE_NAME = 'table_name';
-- SQL Server / MySQL
SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'schema_name' 
	AND TABLE_NAME = 'table_name';
Posted by: Guest on July-04-2021
0

how to get column count

/**
     * Get the column count
     * @return count of column the result set have
     */
    public static int getColumnCount(){

        int columnCount = 0;

        try {
            ResultSetMetaData rsMetaData = rs.getMetaData();
            columnCount = rsMetaData.getColumnCount();
        } catch (SQLException e) {
            System.out.println("ERROW WHILE GETTING COLUMN COUNT " +e.getMessage());
        }
        return columnCount;
    }
Posted by: Guest on November-30-2020

Code answers related to "count number of column in a result table"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language