
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 4381 Articles for MySQL

1K+ Views
Yes, we can include a number for column name in MySQL. We need to use the symbol backtick, which is as follows( ` `)To understand, we will make a table with the help of CREATE command. Let us create a table −mysql> CREATE table NumberColumnDemo -> ( -> `123` varchar(100) -> ); Query OK, 0 rows affected (0.51 sec)Above, I have created a column name as a number with the help of backtick symbol.Now, we can check the same by inserting records with the help of INSERT command. Let us insert a record, which is as follows −mysql> INSERT into ... Read More

6K+ Views
To understand whether a column exist or not, we have the following approaches −With the help of DESC commandUsing SHOW commandFirstly, we will create a table with columns −mysql> CREATE table ColumnExistDemo -> ( -> UniqueId int, -> UniqueName varchar(200), -> UniqueAddress varchar(200) -> ); Query OK, 0 rows affected (0.57 sec)In the first approach, we will get the entire column name with meaningful information. The syntax is as follows −DESC yourTableName; Let us apply the above query to check whether the column name exists or not. However, this approach is not good since it display all the columns.mysql> DESC ... Read More

3K+ Views
The 1046 error occurs if you forget to select any database before creating a table. Let us see how and why this error occurs. We will try to create a table without selecting a database − mysql> CREATE table MyTable1 -> ( -> id int -> ); ERROR 1046 (3D000): No database selected Or mysql> INSERT into sample values(1); ERROR 1046 (3D000): No database selected Look at the output above, we are getting the same 1046 error: “No database selected” Now, we can resolve this error after selecting any ... Read More

966 Views
To open root access from all hosts, we need to change the database to “mysql” with the help of USE command. The syntax of USE command is as follows − USE anyDatabasename; Now, I will use predefined database ‘mysql’, which is as follows − mysql> use mysql; Database changed I have changed the database above. Here is the query to get root access from the entire host − mysql> UPDATE user set host='%' where host='localhost'; Query OK, 6 rows affected (0.19 sec) Rows matched: 6 Changed: 6 Warnings: 0

380 Views
Firstly, we need to create a table to understand the limit clause (as we want for SQL server).We will create a table with the help of CREATE command.Creating a tablemysql> CREATE table limitDemo -> ( -> id int, -> primary key(id) -> ); Query OK, 0 rows affected (0.58 sec)After that, let us insert records into the table −mysql> INSERT into limitDemo values(1); Query OK, 1 row affected (0.16 sec) mysql> INSERT into limitDemo values(2); Query OK, 1 row affected (0.12 sec) mysql> INSERT into limitDemo values(3); Query OK, 1 row affected (0.11 sec) mysql> INSERT into ... Read More

229 Views
We can achieve this with the help of SHOW command. Firstly, I will use my database with the help of USE command −mysql> USE business; Database changedWe are in the “business” database now. After that, we can check that how many tables are available for this database. The query is as follows −mysql> SHOW tables; The following is the output+------------------------+ | Tables_in_business | +------------------------+ | addcolumntable | | autoincrement | | autoincrementtable | | bookindexes | | chardemo ... Read More

2K+ Views
To add 5 hours in current time, we will use now() function from MySQL. The syntax is as follows −SELECT date_add(now(),interval some integer value hour);Now, I am applying the above query to add 5 hours to current time. The query is as follows −mysql> SELECT date_add(now(),interval 5 hour); The following is the output+---------------------------------+ | date_add(now(),interval 5 hour) | +---------------------------------+ | 2018-10-11 15:59:23 | +---------------------------------+ 1 row in set (0.00 sec)Look at the output above, it has increased the current time by 5 hours

298 Views
Both are engine types. Here is the query by which we can get to know which engine type and tables are being used. Firstly, we will choose the database with the help of USE command − mysql> USE business; Database changed Here is the query through which we can know which table or engine is being used − mysql> SHOW table status; The following is the output +------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+ |Name | Engine | Version | Row_format | ... Read More

360 Views
Firstly, we will check which MySQL version is currently being used with the help of version() function −The query is as follows −mysql> SELECT version();The following is the output+-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)As you can see in the above output, version 8.0.12 is being used. Now, we can check the current character encoding using the following syntax −SELECT CCSA.character_set_name FROM information_schema.`TABLES`T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name -> =T.table_collation AND T.table_schema = "yourDatabaseName" AND T.table_name = "yourTableName";Apply the above query −mysql> SELECT CCSA.character_set_name FROM information_schema.`TABLES`T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name ... Read More

255 Views
It is very difficult to say whether to prefer one large table or multiple small tables. It depends − On the application we are using. On database normalization However, there are many key points, through which we can say that multiple small tables are good in that situation. Suppose many developers are going to develop multiple tables, then there is a need to split them into multiple small tables. A situation when you are giving authority to many developers. This authority is for different parts of data. In this case, a need arise to split into multiple small ... Read More