- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 6702 Articles for Database
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
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
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
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
331 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
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
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
470 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)
81 Views
Following are the ways with the help of which current MySQL transaction can be ended implicitly −By Running DDL statementThe current MySQL transaction will end implicitly and changes will be committed by running any of the DDL statement such as CREATE or DROP databases, Create, ALTER or DROP tables or stored routines. It is because, in MySQL, these statements cannot be rolled back.Examplemysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO MARKS Values(3, 'gaurav', 'Comp', 69); Query OK, 1 row affected (0.26 sec) mysql> Create table student(id int, Name Varchar(10), ); Query OK, 0 ... Read More
368 Views
By using \G at the end of MySQL statement, it returns the output in a vertical format rather than a tabular format. Consider the example below −mysql> Select curdate(); +------------+ | curdate() | +------------+ | 2017-11-06 | +------------+ 1 row in set (0.00 sec) mysql> Select CURDATE()\G *************************** 1. row *************************** CURDATE(): 2017-11-06 1 row in set (0.00 sec)From the example above, the difference of using \G at the end of the MySQL statement can be understood. It returns the same output in a vertical format rather than a tabular format.