How would you discover names of all tables in a database is a current SQL inquiries questions solicited to one from my companion. There are numerous approaches to locate every single table name shape any database like MySQL and SQL Server. You can get table names either from INFORMATION_SCHEMA or sys.tables based upon whether you are utilizing MySQL or Sql Server database. This is not a mainstream address like when to utilize truncate and erase or related versus noncorrelated subquery which you can expect all applicant plan well however this is very normal on the off chance that you are dealing with any database e.g. MySQL. In this SQL instructional exercise we will see cases of getting names of all tables from MySQL and SQL Server database. In MySQL there are two approaches to discover names of all tables, either by utilizing "appear" watchword or by question INFORMATION_SCHEMA. In the event of SQL Server or MSSQL, You can either utilize sys.tables or INFORMATION_SCHEMA to get every single table name for a database. Coincidentally in the event that you are new in MySQL server and investigating it , you may discover this rundown of regularly utilized MySQL server charges helpful.

SELECT table_name FROM information_schema.tables WHERE table_type = 'base table' AND table_schema='test';
+------------+
| TABLE_NAME |
+------------+
| department |
| employee   |
| role       |
| user       |
+------------+
4 rows in set (0.00 sec)

mysql> SHOW tables;
+----------------+
| Tables_in_test |
+----------------+
| department     |
| employee       |
| role           |
| user           |
+----------------+
4 rows in set (0.00 sec)
by Govind Oza . Powered by Blogger.

PHP Frameworks

Popular Posts