- 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
The max_heap_table_size is a system variable that has both read/write property.Initially, max_heap_table_size has size 16 MB. First, check the value of max_heap_table_size, which is in bytes.The query is as follows −mysql> select @@max_heap_table_size;The following is the output −+-----------------------+ | @@max_heap_table_size | +-----------------------+ | 16777216 | +-----------------------+ 1 row in set (0.00 sec)Now let us how the value 16777216 byte = 16 MB −1 MB = 1024KB 1KB = 1024 Bytes 1MB = 1024*1024 bytes. To convert 16777216 byte to MB you need to divide 1024*1024. =16777216/(1024*1024) =16777216/1048576 ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
You can achieve this with the help of CONCAT() along with REPLACE() function. To find the first occurrences you need to use INSTR() function.The syntax is as follows −UPDATE yourTableName SET UserPost = CONCAT(REPLACE(LEFT(yourColumnName, INSTR(yourColumnName, 'k')), 'k', 'i'), SUBSTRING(yourColumnName, INSTR(yourColumnName, 'k') + 1));To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table UserInformation -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(10), -> UserPost text -> ); Query OK, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
139 Views
You can achieve this with the help of ORDER BY CASE statement. The syntax is as follows −SELECT *FROM yourTableName ORDER BY CASE yourIntegerColumnName1 WHEN 2 THEN 1 ELSE 0 END DESC ,yourDateColumnName ASC;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OrderByCaseDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> GroupId int, -> ArrivalDate date, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.57 sec)Insert some records in the table using insert command. The query is as ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
505 Views
To extract filenames from a path MySQL, you can use SUBSTRING_INDEX(). The syntax is as follows −SELECT SUBSTRING_INDEX(ypurColumnName, '\', -1) as anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ExtractFileNameDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> AllProgrammingFilePath varchar(100) -> ); Query OK, 0 rows affected (0.50 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into ExtractFileNameDemo(AllProgrammingFilePath) ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
605 Views
There is no standard function to get week of month in MySQL. You need to use the following syntax −SELECT WEEK(yourDateColumnName, 5) - WEEK(DATE_SUB(yourDateColumnName, INTERVAL DAYOFMONTH(yourDateColumnName) - 1 DAY), 5) + 1 AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table FirstWeekOfMonth -> ( -> Id int NOT NULL AUTO_INCREMENT primary key, -> yourdate date -> ); Query OK, 0 rows affected (2.50 sec)Now you can insert some records in the table ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
196 Views
You need to use ORDER BY clause to sort. The syntax is as follows −SELECT *FROM yourTableName ORDER BY yourColumnName='yourValue' DESC, yourIdColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table SortCertainValues -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> CountryName varchar(10), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.36 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into SortCertainValues(Name, CountryName) values('Adam', 'US'); Query OK, 1 row ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
422 Views
Yes, you can use InnoDB and MyISAM tables in one database or combine both of them in a single database. This is the recommended way.Here is the demo of both MyISAM and InnoDB in a one database. The following is the database and both the table types InnoDB and MyISAM. The query to create a database is as follows −mysql> create database BothInnoDBandMyISAM; Query OK, 1 row affected (0.20 sec) mysql> use BothInnoDBandMyISAM; Database changedI have a database with name ‘BothInnoDBandMyISAM’.First the table has engine type InnoDB. The query to create a table with engine InnoDB is as follows −mysql> ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
5K+ Views
You need to use the CAST operator along with CONV() function. The CONV() function can be used to convert one base number system to another base system.For Example, The 16 is one base system and 10 is another base system. The 16 base system is hexadecimal and 10 is a decimal.The syntax is as follows −SELECT CAST(CONV('yourColumnName', 16, 10) AS UNSIGNED INTEGER) as anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table castTypeToBigIntDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ Views
To update the decimal column to allow more digit, use the MODIFY COLUMN. The syntax is as follows:ALTER TABLE MODIFY COLUMN yourColumnName DECIMAL(yourIntValue, yourIntValue);To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table allowDecimalWithMoreDigit -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Salary DECIMAL(3, 2), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.64 sec)Now you can check the description of table using DESC command. The syntax is as follows:DESC yourTableName;Now you can check the description of table using above ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
695 Views
The AUTO_INCREMENT=5 in a create table query tells that the first record will start from 5 i.e. not default 1. As we know if you do not set the value to AUTO_INCREMENT then MySQL starts from 1 by default.The syntax is as follows:CREATE TABLE yourTableName ( yourColumnName1 dataType NOT NULL AUTO_INCRMENT, . . . N, PRIMARY KEY(yourColumnName1 ) )AUTO_INCREMENT=5;To understand the above syntax, let us create a table.Case1 − The table starts auto increment from 1 because it is the default standard.The query to create a table is as follows:mysql> create table defaultAutoIncrementDemo -> ( -> Id int ... Read More