Posts Tagged ‘table’

Largest Tables in MySQL

Largest Tables in MySQL: Following query will give largest tables of entire MySQL. SELECT table_schema as ‘Database’, table_name AS ‘Table’, round(((data_length + index_length) / 1024 / 1024), 2) ‘Size in MB’ FROM information_schema.TABLES ORDER BY (data_length + index_length); Output

How to get table size in MySQL

How to get table size in MySQL: We can get this information from the schema ‘information_schema’. Query: SELECT table_name AS ‘Table’, round(((data_length + index_length) / 1024 / 1024), 2) ‘Size in MB’ FROM information_schema.TABLES WHERE table_schema = “sakila” AND table_name = “rental”;

Rename table in MySQL

RENAME TABLE is used to change the name of table. We must have ALTER and DROP privileges for the original table, and CREATE and INSERT privileges for the new table.

Copy a table structure in MySQL

We can clone or copy a table structure in MySQL using LIKE or AS operators. Using LIKE: We can use CREATE TABLE … LIKE to create an empty table based on the definition of another table, including any column fields and indexes defined in the original table: Syntax: CREATE TABLE new_table LIKE original_table;

emp table script MySQL

Standard emp table script for MySQL Server 1) Create table structure 2) Insert data into emp table

emp table script PostgreSQL

Standard emp table script for PostgreSQL 1) Create table structure 2) Insert data into emp table

Table definition in SQL Server

If we want to see the table definition in SQL Server, then we can get using sp_help procedure. Syntax: sp_helptext [ @objname = ] ‘name’ [ , [ @columnname = ] computed_column_name ]

emp table script SQL Server

Standard emp table script for SQL Server 1) Create table structure 2) Insert data into emp table

Powered by k2schools