Found 4378 Articles for MySQL

What happens to the current MySQL transaction if the session is killed by DBA?

Swarali Sree
Updated on 27-Feb-2020 11:09:23

542 Views

Suppose if a session is killed in the middle of a transaction then that current MySQL transaction will be rolled back by MySQL and ended. It means that all the database changes made in the current transaction will be removed. It is called n implicit rollback when the session is killed.ExampleSuppose we have the following values in the table ‘marks’mysql> Select * from marks; +------+---------+-----------+-------+ | Id   | Name    | Subject   | Marks | +------+---------+-----------+-------+ |    1 | Aarav   | Maths     |    50 | |    1 | Harshit | Maths   ... Read More

How to use ALTER TABLE statement for changing the size of a column in MySQL?

Daniol Thomas
Updated on 22-Jun-2020 11:29:02

77 Views

It can be understood with the help of the following example using the table named ‘Student’ having the following description −mysql> DESCRIBE Student; +--------+-------------+------+-----+---------+-------+ | Field  | Type        | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | Name   | varchar(20) | YES  |     | NULL    |       | | RollNo | int(11)     | YES  |     | NULL    |       | | Grade  | varchar(10) | YES  |     | NULL    |       | +--------+-------------+------+-----+---------+-------+ 3 rows in set ... Read More

What would be the result if we perform any kind of arithmetic calculations in MySQL having one of the arguments as NULL?

radhakrishna
Updated on 22-Jun-2020 11:33:08

71 Views

MySQL always throws NULL as the result of arithmetic calculations in which one of the arguments is NULL. Consider the following example having NULL as an argument with addition, subtraction, multiplication, and division −mysql> Select 10*NULL; +---------+ | 10*NULL | +---------+ |    NULL | +---------+ 1 row in set (0.12 sec) mysql> Select 10+NULL; +---------+ | 10+NULL | +---------+ | NULL | +---------+ 1 row in set (0.00 sec) mysql> Select 10-NULL; +---------+ | 10-NULL | +---------+ |    NULL | +---------+ 1 row in set (0.07 sec) mysql> Select 10/NULL; +---------+ | 10/NULL | +---------+ ... Read More

How can we use both built-in-commands (G & g) and semicolon (;) in a single MySQL statement?

Krantik Chavan
Updated on 22-Jun-2020 11:32:31

96 Views

As we know that built-in-commands (\G and \g) send the command to MySQL server for execution and with the help of Semicolon (;) MySQL determines the end of the statement. For using all three and getting the result without error, we need to write three queries, one query with \G, one with \g and other with a semicolon (;) in the end, in a single statement.Examplemysql> Select * from student\G select * from ratelist\g select NOW(); *************************** 1. row ***************************   Name: Gaurav RollNo: 100  Grade: B.tech *************************** 2. row ***************************   Name: Aarav RollNo: 150  Grade: M.SC *************************** 3. ... Read More

How can I combine the built-in-commands (g and G), used for executing a MySQL statement, with each other?

mkotla
Updated on 22-Jun-2020 11:33:43

62 Views

As we know that built-in-commands (\G and \g) send the command to MySQL server for execution and both of them have the different format of the result set. For combining them and getting the result without error, we need to write two queries, one query with \G and other with \g at the end, in a single statement.Examplemysql> Select * from student\G select * from ratelist\g *************************** 1. row ***************************   Name: Gaurav RollNo: 100  Grade: B.tech *************************** 2. row ***************************   Name: Aarav RollNo: 150  Grade: M.SC *************************** 3. row ***************************   Name: Aryan RollNo: 165  Grade: M.tech 3 ... Read More

How can I combine built-in-commands (g and G), used for executing a MySQL statement, with termination symbol semicolon (;) to get output without any error?

Nishtha Thakur
Updated on 22-Jun-2020 11:20:38

70 Views

As we know that built-in-commands (\G and \g) send the command to MySQL server for execution and with the help of Semicolon (;) MySQL determines the end of the statement. It is also known that both of them have different format of the result set. For combining them and getting the result without error, we need to write two queries, one query with either \G or \g and other with a semicolon (;) at the end, in a single statement.ExampleCombining \G and Semicolon (;) −mysql> Select * from student\G select * from ratelist; *************************** 1. row ***************************   Name: Gaurav ... Read More

What happens if I use both G and semicolon (;) termination symbol with a single MySQL statement?

Giri Raju
Updated on 22-Jun-2020 11:21:31

329 Views

As we know that \G option sends the command to MySQL server for execution and with the help of Semicolon (;) MySQL determines the end of the statement. It is also known that both of them have a different format of the result set.Now, if we will use both of those in MySQL statement then the output would be produced on the basis that which of them is encountered first by MySQL. For others, MySQL will produce an error. It can be understood with the help of the following example −mysql> Select CURDATE();\G +------------+ | CURDATE()  | +------------+ | 2017-11-06 ... Read More

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

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

63 Views

We can use ROLLBACK command to eliminate the changes, made in a current transaction, permanently from MySQL database. Suppose if we run some DML statements and it updates some data objects, then ROLLBACK command will eliminate these updates permanently from the database. Example Suppose we have the following data in table ‘marks’ and we applied the transaction and ROLLBACK command as follows − mysql> SELECT * FROM Marks; +------+---------+---------+-------+ | Id | Name | Subject | Marks | +------+---------+---------+-------+ | 1 | Aarav | Maths | ... Read More

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

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

253 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 (0.00 sec) mysql> INSERT INTO Marks Values(1, 'Aarav', 'Maths', 50); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO Marks Values(2, 'Harshit', 'Maths', 55); Query OK, 1 row affected (0.00 sec) mysql> COMMIT; Query OK, 0 rows affected (0.06 sec)In this example, the COMMIT statement will ... Read More

How can we find out the current transaction mode in MySQL?

Monica Mona
Updated on 14-Feb-2020 06:10:57

463 Views

We can run “SELECT @@AUTOCOMMIT” command to check the current transaction mode.mysql> Select @@AUTOCOMMIT; +--------------------+ | @@AUTOCOMMIT       | +--------------------+ |       1            | +--------------------+ 1 row in set (0.05 sec) mysql> SET AUTOCOMMIT = 0; Query OK, 0 rows affected (0.00 sec) mysql> Select @@AUTOCOMMIT; +--------------------+ | @@AUTOCOMMIT       | +--------------------+ |         0          | +--------------------+ 1 row in set (0.00 sec)

Advertisements