Introduction
Tables organize data in a simple way using rows and columns. This helps us store and find information easily.
Tables organize data in a simple way using rows and columns. This helps us store and find information easily.
CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype );
Customers with three columns: an ID number, a name, and a city.CREATE TABLE Customers ( CustomerID INT, CustomerName VARCHAR(100), City VARCHAR(50) );
CREATE TABLE Products ( ProductID INT, ProductName VARCHAR(100), Price DECIMAL(10,2) );
This example creates an Employees table, adds two employees, and then shows all the data in the table.
CREATE TABLE Employees ( EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), JobTitle VARCHAR(50) ); INSERT INTO Employees VALUES (1, 'Alice', 'Smith', 'Manager'); INSERT INTO Employees VALUES (2, 'Bob', 'Brown', 'Sales'); SELECT * FROM Employees;
Each row must have a value for every column unless the column allows empty values.
Column names should be clear to understand what data they hold.
Tables store data in rows and columns.
Rows are individual records.
Columns define the type of data stored.
row represent in a database table?Employees?SELECT * FROM table_name;.Students with columns id, name, and age, what will this query return?SELECT name FROM Students WHERE age > 20;
name column from the table.age is greater than 20, so only those students are included.SELECT id, name FROM Students WHERE age = 'twenty';
age to the string 'twenty', but age is numeric.Orders with columns order_id, customer_id, and amount. You want to find the total amount spent by each customer. Which SQL query correctly groups and sums the data?customer_id.customer_id and sums amount.Pass the test and this pattern moves unknown