Course
Select Database
MySQL Tutorial
This SQL tutorial is structured for beginners to guide them from the foundational concepts to advanced data manipulation and querying techniques in SQL. By the end of this tutorial, you will have developed a robust understanding of SQL, equipping you with the knowledge to efficiently manage and analyze data across various database systems. This guide sets the stage for your growth into a skilled data professional, ready to tackle complex data challenges and contribute to the field of data analysis and database management.
USE Statement
MySQL USE Statement
The USE statement of MySQL helps you to select/use a database. You can also change to another database with this statement. Once you set the current database it will be same until the end of the session unless you change the it.
Syntax
Following is the syntax of the MySQL USE statement
USE db_name
Example
Following example demonstrates the usage of the MySQL USE statement
use test;CREATE TABLE SAMPLE(NAME VARCHAR(10));INSERT INTO SAMPLE VALUES ('Raj');
use sampleDatabase changed
SELECT * FROM SAMPLE;ERROR 1146 (42S02): Table 'sample.sample' doesn't exist
Example
Here we are creating a new database and changing the current database to it.
CREATE DATABASE myDatabase;use myDatabaseDatabase changed