SQL Tutorial

67 / 68

Creating and dropping database

  • A database is set of physical files on the disks in which set of logical objects like tables, views, procedures etc are stored.
  • When MySQL Server starts, it becomes ready to access the database stored on the disks.
    When a user sends a request for read/write from a client machine, MySQL Server process accesses the database stored on the disks and does the needful.
  • When a new database is created, a new set of files are created on the disks corresponding to that database and all data for this database would be stored in those files.
  • By default, only DBAs can create and drop databases but other users can be given permissions to perform these tasks.
  • In MySQL, each database is a collection of tables, indexes, views etc.

  • Creating a database:
    [root@host]# mysqladmin -u root -p create mydb1
    Enter password:**
    mysql> CREATE DATABASE mydb1;

  • Dropping a database:
    [root@host]# mysqladmin -u root -p drop mydb1
    Enter password:**
    mysql> DROP DATABASE mydb1;

  • Switching to a different database:
    When a user connects to MySQL Server, user is not connected to any database by default (until and unless specified in local file .my.cnf).
    User has to use use command to switch and connect to the required database.

    mysql> use retail_db;

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...