Found 4381 Articles for MySQL

What will happen to the current MySQL transaction if a START TRANSACTION command is executed in the middle of that current transaction?

Jai Janardhan
Updated on 22-Jun-2020 11:29:39

204 Views

The current transaction will be committed and ended if START TRANSACTION is executed in the middle of a current transaction. All the database changes made in the current transaction will be made permanent. This is called an implicit commit by a START TRANSACTION command.ExampleSuppose we have the following values in table ‘marks’mysql> select * from marks; +------+---------+-----------+-------+ | Id   | Name    | Subject   | Marks | +------+---------+-----------+-------+ | 1    | Aarav   | Maths     | 50    | | 1    | Harshit | Maths     | 55    | | 3   ... Read More

What will happen to MySQL current transaction, if in the middle of that transaction, the DDL statement is executed?

Chandu yadav
Updated on 22-Jun-2020 11:30:35

329 Views

The current MySQL transaction will be committed and ended when any of the DDL statement such as CREATE or DROP databases, Create, ALTER or DROP tables or stored routines is executed in the middle of the current transaction. All the database changes made in the current transaction will be made permanent and cannot be rolled back.Examplemysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO MARKS Values(6, 'Manak', 'History', 70); Query OK, 1 row affected (0.26 sec) mysql> Create table student(id int, Name Varchar(10), ); Query OK, 0 rows affected (0.84 sec)As we can see ... Read More

What happens to the current MySQL transaction if the session is ended in the middle of a transaction?

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

171 Views

Suppose if a session is ended 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 ended.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

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

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

696 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

131 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

123 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

165 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

102 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

122 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

448 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

Advertisements