TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    MySQL

    MySQL USE Statement

    Overview

    In this tutorial, we will learn about MySQL USE Statement with some examples. The USE statement specifies he current default database. It is used to select the default database for the subsequent MySQL commands. We can switch to another database by issuing another USE statement.

    Syntax

    The general syntax of the USE statement is shown as follows:

    USE <database_name>

    This statement allows us to refer to the database tables without explicitly specifying the database where the table resides. For example, City table resides in the world database. Using this statement, we can refer to the table simply as City instead of world.City

    Note that we can refer to tables in other database schema using the schema name as follows:

    <schema_name>.<table_name>

    Example

    Let’s look at some examples.

    To select a database named world as the current database, we need to issue the following command at the mysql> prompt.

    mysql> USE world;

    The semi-colon is optional for this statement. The ideal response for the command is ‘Database changed’

    MySQL USE statement

    The world database remains the default until the end of the session or until another USE statement is issued. To switch to other database, we can issue another USE command.

    To get Help

    To get help, issue the following command

    mysql> HELP USE

    Common Error

    Trying to use non existent database.

    mysql> USE testdb;
    ERROR 1049 (42000): Unknown database ‘testdb’

    —

    MySQL Tutorials

    MySQL Tutorials on this website:

    https://www.testingdocs.com/mysql-tutorials-for-beginners/

    For more information on MySQL Database:

    https://www.mysql.com/

    Related Posts

    Stellar Converter for Database

    MySQL /

    Stellar Converter for Database

    Stellar MySQL Log Analyzer

    MySQL /

    Stellar Log Analyzer for MySQL

    Stellar Repair for MySQL

    MySQL /

    Stellar Repair for MySQL

    MySQL /

    How to secure your SQL Database: Tips and Tricks

    Stellar Converter for Database

    MySQL /

    Database Converter Tools

    ‹ MySQL DROP DATABASE Statement› MySQL Datatypes

    Recent Posts

    • ChatGPT Subscription Plans
    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • ChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com