0
0
SQLquery~5 mins

What is a database in SQL

Choose your learning style9 modes available
Introduction

A database is a place where you store information so you can find and use it easily later.

Keeping track of your contacts and phone numbers
Storing all the books in a library with details like title and author
Saving customer orders in a shop to know what was bought
Recording student grades and attendance in a school
Managing employee information in a company
Syntax
SQL
No specific code for 'What is a database' as it is a concept, not a command.
A database organizes data in tables with rows and columns.
You use special languages like SQL to work with databases.
Examples
This creates a table named Contacts to store names and phone numbers.
SQL
-- Example of a table in a database
CREATE TABLE Contacts (
  ID INT,
  Name VARCHAR(100),
  Phone VARCHAR(15)
);
This adds one contact named Alice with her phone number.
SQL
-- Adding data to the Contacts table
INSERT INTO Contacts (ID, Name, Phone) VALUES (1, 'Alice', '123-4567');
Sample Program

This example creates a Books table, adds two books, and then shows all books stored.

SQL
CREATE TABLE Books (
  BookID INT,
  Title VARCHAR(100),
  Author VARCHAR(100)
);

INSERT INTO Books (BookID, Title, Author) VALUES
(1, 'The Little Prince', 'Antoine de Saint-Exupéry'),
(2, 'Harry Potter', 'J.K. Rowling');

SELECT * FROM Books;
OutputSuccess
Important Notes

Think of a database like a digital filing cabinet for your information.

Databases help keep data safe and easy to find.

Summary

A database stores information in an organized way.

It uses tables with rows and columns to hold data.

You use commands like CREATE, INSERT, and SELECT to work with data.