What is a database? How to create and use a database?

Pradnyankur Nikam
A free video tutorial from Pradnyankur Nikam
Freelance Web developer and Instructor, 9000+ Happy Students
4.3 instructor rating • 2 courses • 9,659 students

Lecture description

Lets understand about the database and create our first database. Also execute the SQL statement to select or use an existing database.

Learn more from the full course

SQL Tutorial: Learn SQL with MySQL Database -Beginner2Expert

Learn SQL and Database Development to work effectively in DBMS like MySQL, SQL Server, Oracle, PostgreSQL, DB2 etc.

10:46:53 of on-demand video • Updated November 2021

  • Understand the Database terminology & Structured Query Language fundamentals.
  • At the end of this course, You will be able to use SQL statements in any database management system.
  • You will learn from SQL basics to advanced topics like JOINS, Database Relationships, Database Normalization.
  • You will learn each topic step by step with practical examples.
  • You will learn the skills useful for professional Database Development (Database Modeling) and Database Management.
  • You will also learn about MySQL Workbench, a unified visual tool for database architects, developers, and Database Administrators.
English The structured query language is all about databases. Therefore, we must first understand what a database is? The database is a structured set of information or data organized in such a way that a computer program can quickly access, manage and update it. In other words, Database is a collection of one or more tables and the tables contain "data rows" or "data records". Imagine database with an example of a refrigerator. The refrigerator is a database. The various compartments in the refrigerator are tables. And the vegetables, foods and beverages stored inside refrigerator's compartments are the data. To interact with any database first the user must have an appropriate privileges to access the database. Secondly the user must select the database before executing any SQL statement. The SQL statement to display an existing databases is, "SHOW DATABASES;" The SQL statement will return all the existing databases in our database management software. The SQL statement to create a new database is, "CREATE DATABASE school;" Where "school" is the new database name. To use a database the SQL statement is again very simple, "USE school;" Where "school" is an existing database name. And the SQL statement to delete a database is, "DROP DATABASE school;" Where "school" is an existing database name. Now lets learn with practical examples. Here, I have logged in, in my MySQL database server using my "root" username and password. Lets display all existing databases using the SQL statement, "SHOW DATABASES;" By default MySQL database server creates a couple of system databases, which stores all the users information likes username, password, privileges and so on and other database related settings. Now lets create a new database named "school". We will store students information in this database. Please Note: To create a new database, the logged in user must have "data definition language" privilege, that is the privilege to CREATE, SELECT, ALTER and DROP the database. We will learn about data definition language in next couple of lectures. The SQL statement to create a new database is, "CREATE DATABASE school;" (Here school is the name of our database). Hit Enter And you will get Query OK 1 rows affected message. That is the new database has been created. Now enter, "SHOW DATABASES;" SQL statement again. and you can see the new database "school" is created. To use the newly created database, we will have to select it. and the SQL statement to use the database is, "USE school;" You will get the database changed message. At the moment our database is empty, there are no tables or data rows inside the new database. We will create and populate the table with data in next lecture. In this lecture will use and display data from another database. Type, "USE mysql;" (to use MySQL's default database.) Now enter the SQL statement, "SELECT User FROM User;" The query will return all the usernames that exists in the "User" table of "mysql" database. Notice the username "admin" we created in previous section. Finally, lets remove the newly created database. And SQL statement to delete a database is "DROP DATABASE school;" Here school is the name of our database. We will get Query OK 0 rows affected message, that is our database is removed. Now again type "SHOW DATABASES;" SQL statement, to display the list of all the existing databases. and you can see, the "school" database is gone. In this lecture we learned how to create and use and drop the database. We will explore more database related SQL statements in later sections of this course.