How can I get the number of rows and columns that are in an SQL table?
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Thank you for such a lovely short question. The number of rows is easy:
select count(*) as rows from daTable
As for the number of columns, that's a bit trickier:
select count(*) as columns from information_schema.columns where table_name = 'daTable'
The INFORMATION_SCHEMA tables (actually, they're views) are the standard SQL way of storing information about your database, and you are allowed to query them too.
Dig Deeper on Oracle and SQL
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback.continue reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback.continue reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clausecontinue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.