I\'ve searched through a bunch of websites and I have not come across any code or tutorial which has gone through the specifics of obtaining the table names from a single da
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'
In MySQL this will list all databases:
show databases;
For each of these you can do:
use <database_name>;
and then
show tables;
if you are asking about .net code then You need SMO :
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
public static List<Table> GetTables(string connection, string databaseName)
{
if (String.IsNullOrEmpty(connection))
throw new ArgumentException("connection is null or empty.", "connection");
Server srv = getServer(connection);
return srv.Databases[databaseName].Tables.Cast<Table>().ToList();
}
In SQL SERVER, you can just use -
select * from sys.tables
I used this query:
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'
It gives me table name as well as sysDiagram(database diagram generated for that database)
Here is the MySQL query you asked.
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mp21'