Rama Giri has Published 110 Articles

How changes, made in the current transaction, can be permanently recordedin MySQL database?

Rama Giri

Rama Giri

Updated on 22-Jun-2020 11:22:31

245 Views

We can use COMMIT command to make the changes, made in a current transaction, permanently recorded in MySQL database. Suppose if we run some DML statements and it updates some data objects, then COMMIT command will record these updates permanently in the database.Examplemysql> START TRANSACTION; Query OK, 0 rows affected ... Read More

What MySQL MAKE_SET() function returns if there are all NULL at the place of strings?

Rama Giri

Rama Giri

Updated on 22-Jun-2020 07:50:32

51 Views

MySQL MAKE_SET() function will return nothing if there are all NULL at the place of strings. Following example will demonstrate it −Examplemysql> Select MAKE_SET(2, NULL,NULL,NULL); +-----------------------------+ | MAKE_SET(2, NULL,NULL,NULL) | +-----------------------------+ |                             | +-----------------------------+ 1 row in set (0.00 sec)

In MySQL, how IN() comparison function works?

Rama Giri

Rama Giri

Updated on 22-Jun-2020 06:42:32

71 Views

Basically, IN() comparison function checks whether a value is within a set of values or not. If the value is within a set of values then it returns 1 otherwise 0. Its syntax can be as follows;Expression IN (val1, val2, …, valN)Here, The expression is the value that is to ... Read More

How MySQL evaluates if I will use an expression within SUM() function?

Rama Giri

Rama Giri

Updated on 22-Jun-2020 05:31:13

81 Views

When we include an expression within SUM() function then MySQL evaluates it for each row of data and the total result is returned. To understand it, consider the following example of table ‘employee’, having the following details −mysql> Select * from Employee; +----+--------+--------+ | ID | Name   | Salary ... Read More

While adding the numbers contained in quotes, how MySQL evaluates if we write non-numeric text after a number?

Rama Giri

Rama Giri

Updated on 20-Jun-2020 13:47:16

45 Views

Suppose if we are trying to add the numbers having non-numeric text after them, then MySQL simply discard the non-numeric text and evaluates the addition of numeric values along with warnings. Following example will exhibit this −Examplemysql> Select '1525 Kg' + '200 Oz'As Total; +-------+ | Total | +-------+ | ... Read More

What happens if I pass only one argument to the MySQL CONCAT() function?

Rama Giri

Rama Giri

Updated on 20-Jun-2020 08:21:10

118 Views

MySQL allows us to pass only one argument to the CONCAT() function. In this case, MySQL returns the same argument as output. Following example will exhibit it −Examplemysql> Select Concat('Delhi'); +-----------------+ | Concat('Delhi') | +-----------------+ | Delhi           | +-----------------+ 1 row in set (0.00 sec)

How can we add multiple columns, with single command, to an existing MySQL table?

Rama Giri

Rama Giri

Updated on 20-Jun-2020 05:53:09

5K+ Views

We can also add multiple columns to an existing table with the help of ALTER command. The syntax for it would be as follows −SyntaxAlter table table-name ADD (column-name1 datatype, column-name2 datatype, … column-nameN datatype);ExampleIn the example below, with the help of ALTER Command, columns ‘Address’, ‘Phone’ and ‘Email’ are ... Read More

How can we emulate CHECK CONSTRAINT by using triggers?

Rama Giri

Rama Giri

Updated on 19-Jun-2020 13:38:03

126 Views

As we know that MySQL supports foreign key for referential integrity but it does not support CHECK constraint. But we can emulate them by using triggers. It can be illustrated with the help of an example given below −ExampleSuppose we have a table named ‘car’ which can have the fix ... Read More

How to disable MySQL foreign key checks and what are the benefits ofdisabling it?

Rama Giri

Rama Giri

Updated on 19-Jun-2020 13:27:24

188 Views

We can disable foreign key checks with the help of the following statement −mysql> Set foreign_key_checks = 0; Query OK, 0 rows affected (0.00 sec)And we can enable it with the help of the following statement −mysql> Set foreign_key_checks = 1; Query OK, 0 rows affected (0.00 sec)Some benefits of ... Read More

What is the difference between equals and compareTo in Java?

Rama Giri

Rama Giri

Updated on 18-Jun-2020 07:22:14

2K+ Views

The compareTo() method compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argument string.The result is a negative integer if this String object ... Read More

Advertisements