MySQL Articles

Page 352 of 355

How to get the size of the tables of a MySQL database?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 458 Views

To get the size of the tables of a MySQL database, you can use the “information_schema.tables”. Here is the syntax to know the size of all tables. SELECT TABLE_NAME AS `ALLTABLESNAME`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `TABLESIZEIN(MB)` FROM information_schema.TABLES WHERE TABLE_SCHEMA = "yourDatabaseName" ORDER BY (DATA_LENGTH + INDEX_LENGTH) ASC; Let us apply the above syntax to get the size of the tables. mysql> SELECT TABLE_NAME AS `ALLTABLESNAME`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `TABLESIZEIN(MB)` -> FROM information_schema.TABLES WHERE TABLE_SCHEMA = "business" ...

Read More

How to write Python CGI program to interact with MySQL?

Arnab Chakraborty
Arnab Chakraborty
Updated on 30-Jul-2019 1K+ Views

suppose you want to login into you account using Python CGi script, below is the details login.html email: password: login.py #!C:\Python27\python.exe import MySQLdb import cgi import Cookie # Open database connection db = MySQLdb.connect("localhost", "root", "", "student" ) # prepare a ...

Read More

Are MySQL database and table names case-sensitive?

Monica Mona
Monica Mona
Updated on 30-Jul-2019 1K+ Views

Actually, the case sensitivity of database and table name depends a lot on the case sensitivity of the underlying operating system. Hence, we can say that such names are not case sensitive in Windows but are case sensitive in most varieties of Unix.

Read More

How to get the list of tables in default MySQL database?

George John
George John
Updated on 30-Jul-2019 522 Views

As we know that the default MySQL database would be the database that is currently in use for subsequent queries. We can get the list of tables in that database by using SHOW TABLES statement. mysql> SHOW TABLES; +------------------+ | Tables_in_sample | +------------------+ | employee | | new_student | | student | +------------------+ 3 rows in set (0.00 sec) The above statement shows the list of table in Sampledatabase.

Read More

In the query [SELECT column1, column2 FROM table_name WHERE condition; ] which clause among 'SELECT', 'WHERE' and 'FROM' is evaluated in the last by the database server and why?

Sai Subramanyam
Sai Subramanyam
Updated on 30-Jul-2019 533 Views

As we know that SELECT clause is used to show all the rows and columns hence SELECT clause is evaluated in the last by the database server.

Read More

What will happen if the MySQL AUTO_INCREMENT column reaches the upper limit of the data type?

vanithasree
vanithasree
Updated on 30-Jul-2019 858 Views

When the AUTO_INCREMENT column reaches the upper limit of data type then the subsequent effort to generate the sequence number fails. That is why it is advised to use a large enough integer data type for the AUTO_INCREMENT column to hold the maximum sequence value required by us. For example, if we will use TINYINT then AUTO_INCREMENT would be able to generate only 127 sequence numbers and in case of UNSIGNED TINYINT, this value can be extended up to 255.

Read More

In MySQL, why a client cannot use a user-defined variable defined by another client?

Sreemaha
Sreemaha
Updated on 30-Jul-2019 328 Views

In MySQL, a user-defined variable defined by one client cannot be seen or used by another client because user-defined variables are connection-specific. It means that all variables for a given client connection are automatically freed when that client exits

Read More

How Can we permanently define user-defined variable for a client in MySQL?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 348 Views

In MySQL, it is not possible that a client can hold user variable permanently. It is because all the variables for a given client connection are automatically freed when that client exits.

Read More

How can we add a FOREIGN KEY constraint to the field of an existing MySQL table?

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 2K+ Views

We can add a FOREIGN KEY constraint to a column of an existing MySQL table with the help of ALTER TABLE statement. Syntax ALTER TABLE table_name ADD FOREIGN KEY (colum_name) REFERENCES table having Primary Key(column_name); Example Suppose we want to add a FOREIGN KEY constraint on the table ‘Orders1’ referencing to the table ‘Customer’ which have column ‘Cust_Id’ as the Primary Key. It can be done with the help of the following query − mysql> Alter table orders1 add FOREIGN KEY(Cust_id) REFERENCES Customer(Cust_id); Query OK, 0 rows affected (0.21 sec) Records: 0  Duplicates: 0  Warnings: 0   mysql> ...

Read More

How MySQL LOCATE() function is different from its synonym functions i.e. POSITION() and INSTR() functions?

Rama Giri
Rama Giri
Updated on 30-Jul-2019 626 Views

As all of these functions are used to return the position of a substring within a string but LOCATE() function is a bit different from POSITION() and INSTR() function. In both POSITION() AND INSTR() functions, we cannot manage the starting position of search with the help of argument as position argument in LOCATE() function. All of these functions are having a difference in syntax also.

Read More
Showing 3511–3520 of 3,547 articles
Advertisements