- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6702 Articles for Database
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
To find the MySQL data directory, we can simply use the variable datadir. Let us see how to use the variable with select statement.The query is as follows −mysql> select @@datadir;Here is the output+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Now we can reach the directory from the above sample output.Here is the snapshot that displays the MySQL data directory.
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
4K+ Views
The foreign_key_checks are session based. Now, we can say that they are for scope i.e. local or global. Here is an example demo of local or global. Both are scopes and we can set this for session.Let us set the scope −mysql> set foreign_key_checks = 0; Query OK, 0 rows affected (0.00 sec) mysql> set global foreign_key_checks = 0; Query OK, 0 rows affected (0.05 sec)The foreign_key_checks variables are server system variables. Here are some more details −PropertyValueSystem Variableforeign_key_checksScopeGlobal, SessionDynamicYesTypeBooleanDefault ValueONSetting foreign_key_checks to 0It affects data definition statements: DROP SCHEMA drops a schema even if it contains tables that have ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
210 Views
To conduct an Accent sensitive search in MySQL, we can use collation with utf8_bin. Here is the syntax to conduct accent sensitive search −yourColumName dataType collate utf8_bin;Apply the above syntax to conduct accent sensitive search. First, let us create a table −mysql> create table AccentSearchDemo -> ( -> Id varchar(100) collate utf8_bin -> ); Query OK, 0 rows affected (0.51 sec)Inserting three records into the table −mysql> insert into AccentSearchDemo values('John123'); Query OK, 1 row affected (0.31 sec) mysql> insert into AccentSearchDemo values('Smith123'); Query OK, 1 row affected (0.15 sec) mysql> ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
4K+ Views
To merge two MySQL tables, use the following syntax −INSERT IGNORE INTO yourTableName1 select *from yourTableName2;We will create two tables with some records. After that the merge process will begin using the above syntax.Creating first table −mysql> create table MergeDemo1 -> ( -> id int, -> primary key(id), -> Name varchar(200) -> ); Query OK, 0 rows affected (1.00 sec)Inserting records into the table −mysql> insert into MergeDemo1 values(1, 'John'); Query OK, 1 row affected (0.21 sec)Displaying records from the tablemysql> select *from MergeDemo1;The following ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
2K+ Views
We can work with nested transactions in MySQL with the help of SAVEPOINT.Firstly, create a table. After that, begin the transaction.Now, insert records in the table created above. Use SAVEPOINT statement to set a named transaction savepoint with a name of identifier.Here are all the steps shown in the form of query −Create tablemysql> create table NestedTransactionDemo -> ( -> Name varchar(200) -> ); Query OK, 0 rows affected (0.63 sec)Start the transaction −mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec)Now, insert a record in the tablemysql> insert into ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
401 Views
To auto generate database diagram in MySQL, use MySQL workbench. For this, select the option from database as shown below −Database->Reverse EngineerHere is the snapshot showing the Database tab −After clicking “Database” above, choose the option “Reverse Engineer”. This state the “Reverse Engineer” mode.Clicking above will display the following table automatically. We had one table in the database “business”. The same table “tblstudent” is visible here −
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
3K+ Views
To update data into a MySQL database table, use UPDATE command. The syntax is as follows −update yourTableName set yourColumnName1 = value1, ....N where condition;First, we need to create a table. The query is as follows −mysql> create table UpdateDemo -> ( -> id int, -> Name varchar(200) -> ); Query OK, 0 rows affected (0.67 sec)Let us insert records into the table. The following is the query −mysql> insert into UpdateDemo values(101, 'John'); Query OK, 1 row affected (0.19 sec) mysql> truncate table UpdateDemo; Query OK, 0 rows affected (0.86 sec) mysql> insert ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
5K+ Views
Delete data from a MySQL database with the help of DELETE command. The syntax is as follows.delete from yourTableName where condition;I will delete data from a MySQL database with the help of JAVA programming language. First, create a table and insert some records. The following is the query to create a table.mysql> create table DeleteTableDemo -> ( -> id int, -> Name varchar(200) -> ); Query OK, 0 rows affected (0.94 sec)Insert records in the above table. The query to insert records is as follows.mysql> insert into DeleteTableDemo values(101, 'Smith'); Query OK, 1 row affected (0.21 ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
287 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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
378 Views
Let us first see how we can display an index from MySQL. For that, use the SHOW command. The query to show an index is as follows − mysql> SHOW INDEX FROM indexingdemo; Here is the output. +--------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | +--------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | indexingdemo | 1 | indexName | ... Read More