Tutorialspoint

ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'?

Ankith Reddy
Answered on 18th Oct, 2018

In the system, the root is defined by another name as well as password. Then the user is created as a root with the help of the create command. This will result in the ERROR 1396. The query for this is given as follows − mysql> create user 'root'@'localhost' ... Read More

How to find out port of MySQL Server?

Maheshwari Thakur
Answered on 18th Oct, 2018

To find the port of the MySQL server, the command show can be used. Its syntax is as follows: show variables where variable_name=’port’; The above syntax is used to get the port number of the MySQL server using the following query − mysql> show variables where variable_name ... Read More

What is the MySQL VARCHAR max size?

George John
Answered on 18th Oct, 2018

The MySQL version before 5.0.3 was capable of storing 255 characters but from the version 5.0.3 , it is capable of storing 65, 535 characters. MySQL official documentation states: The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65, 535 ... Read More

What is the best data type to store money values in MySQL?

Chandu yadav
Answered on 18th Oct, 2018

We can store the money values in MySQL in decimal(value1, value2). Here, value1 is the total range including value2. The value2 specifies the number of digits after the decimal point. To understand this concept, the steps are given below. First a table is created using the create command. mysql> ... Read More

What is “where 1=1” statement in MySQL?

Ankith Reddy
Answered on 18th Oct, 2018

In MySQL “Where 1=1” results in all the rows of a table as this statement is always true. An example to better unerstand this statement is given as follows − First, a table is created with the help of the create command. This is given as follows − mysql> ... Read More

How to change max_allowed_packet size in MySQL?

George John
Answered on 18th Oct, 2018

The max_allowed_packet size is a session variable and is also a read only variable. To check what is the present value of max_allowed_packet, the command show variables is used. It is given as follows − mysql> show variables like 'max_allowed_packet'; The following is the output +--------------------+---------+ | ... Read More

Update a column value, replacing part of a string in MySQL?

Chandu yadav
Answered on 18th Oct, 2018

To update a column value, the update command as well as the replace method can be used. The steps to better understand these are given as follows − First create a table with the help of the create command. This is given as follows − mysql> CREATE table DemoOnReplace ... Read More

How do I see all foreign keys to a table column?

Ankith Reddy
Answered on 18th Oct, 2018

To see all the foreign keys to a table or column, the referenced_column_name command is used. First, two tables are created and then related with the help of the foreign key constraint. Creating the first table − mysql> CREATE table ForeignTable -> ( ... Read More

How to change auto increment number in the beginning in MySQL?

Maheshwari Thakur
Answered on 18th Oct, 2018

The auto_increment is a default property that automatically increments the newly added record by 1. The auto_increment can be changed from the beginning as well. The procedure for that is given below − First, a table is created. mysql> CREATE table DemoAuto -> ( ... Read More

How to change auto increment number in MySQL?

George John
Answered on 18th Oct, 2018

The auto_increment is a default property that automatically increments the newly added record by 1. The starting number can be changed with the help of the alter command. First, a table is created with the help of the insert command. This is given as follows − mysql> CREATE table ... Read More

How to check if a MySQL database exists?

Chandu yadav
Answered on 18th Oct, 2018

The schema_name command is used to check if a MySQL database exists or not. The syntax of this command is as follows − select schema_name from information_schema.schemata where schema_name = 'database name'; Now, the above command is used to check whether the database exists or not. The query ... Read More

MySQL error 1452 - Cannot add or a child row: a foreign key constraint fails

Ankith Reddy
Answered on 18th Oct, 2018

To understand error 1452, first we need to create a table and relate that to another table with the help of a foreign key constraint. Creating the first table − mysql> CREATE table ForeignTable -> ( -> id int, -> ... Read More

How to get the max of two values MySQL?

Maheshwari Thakur
Answered on 18th Oct, 2018

To get the maximum of two values in MySQL, we can use the predefined function “greatest”. The syntax of greatest() function is as follows − SELECT greatest(value1, value2); Applying the above query, To get the maximum value from two values. The query is as follows − Case 1 ... Read More

How to modify the size of column in MySQL table?

George John
Answered on 18th Oct, 2018

We can modify a column size with the help of ALTER command. Let us see how to modify column size. Suppose we are defining any column with some size. At the time of inserting if we are giving more size in comparison to the one we defined, then an error ... Read More

How to declare a variable in MySQL?

Chandu yadav
Answered on 18th Oct, 2018

We can declare a variable in MySQL with the help of SELECT and SET command. Before declaring a variable we need to prefix the symbol ‘@’ The syntax is as follows − SELECT @ yourVariableName; The symbol ‘@’ tells that it is a user defined variable or not. ... Read More

Advertisements
Loading...
Unanswered Questions View All