DATABASE
DATABASE in SQL is a structured set of data. In other words, it is the main container that holds data in an organized way for storing, managing, and retrieval. A DATABASE in SQL consists of series of tables that store specific sets of information. It takes a major role in the functioning of an application by allowing the storage, update, and retrieval of data. A DATABASE follows the ACID principles (Atomicity, Consistency, Isolation, Durability) to ensure reliability.
Example
Output
Explanation
The example demonstrates the procedure of creating a database, using that database, and creating a table inside the database in MySQL. An entry is also inserted into the table and then the contents of the table are displayed.
Example
Output
Explanation
In the example, first, a new database test_db
is created. Then, a connection is established to the new database. Next, a new table test_table
with columns ID
and NAME
is created in the test_db
database. Afterwards, an entry, where ID
is 1
and NAME
is 'John'
, is inserted into test_table
. Finally, using the SELECT
statement, all records from test_table
are retrieved, which currently only holds one entry. As a result, the output shows that single row with ID
equalling 1
and NAME
equalling 'John'
.
Example
Output
Explanation
The above SQL code snippet creates a new database named TestDB
. When executed successfully, the SQL Server returns a message stating that the command(s) completed successfully.
Example
Output
Explanation
In Oracle SQL, the CREATE DATABASE
statement is used to create a new database. In this case, a database named sampleDB
has been created.
Example
Output
Explanation
In this example, a command CREATE DATABASE
is used to create a new database called ‘example_db’. The command creates an entirely new database and an output message “Query OK, 1 row affected” confirms that the command executed successfully and a new database has been created.