"SQL, a powerful language for databases, lets you ask questions of your data and unlock hidden insights, no matter your technical background. With just a few basic SQL commands, you can transform raw data into meaningful information to guide decisions and fuel your projects."- Gemini 2024
In SQL (Structured Query Language), DDL and DML are two essential categories of commands used to interact with databases. DDL defines the structure of a database, and DML is used to manipulate its content.
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
CREATE VIEW
INSERT
SELECT
UPDATE
DELETE
WHERE
SQL (Structured Query Language) reigns supreme as the undisputed king of relational databases. It provides a universal language for interacting with these structured data stores, allowing you to retrieve, manipulate, and analyze information with ease. While the core functionalities remain consistent across SQL dialects, there are variations for specific needs. Popular examples include:
With SQL we can extract data from relational databases and turn the data into information for decision making in business, and exploration in scientific research.
-- Selecting all fields in all records in a table select * from Orders; -- Selecting some fields from all records in a table select first_name, age from Customers; -- Selecting a subset of records select item from Orders where customer_id = 3; select shipping_id from Shippings where status == "Pending"; -- Sorting the output select * from Customers order by "last_name"; -- Getting distinct (unique) values in a field select distinct "item" from Orders; -- Selecting based on different conditions select age from Customers where country == "USA"; select age from Customers where country != "USA"; select age from Customers where country in ("UK", "UAE"); select item from Orders where amount > 500; select item from Orders where amount between 300 and 400; -- Selecting based on multiple conditions with boolean expressions select customer_id from Customers where country == "USA" and age > 30; select customer_id from Customers where country == "USA" or age < 25; select customer_id from Customers where country == "USA" and not age < 25;
Some content on this page partially generated with the help of Gemini, a large language model from Google AI. Learn more about Gemini.