0% found this document useful (0 votes)
10 views1 page

Lec 39 SQL Create Table

The document contains SQL commands to create two tables: Customers and Orders, with specified fields and relationships. It includes the insertion of sample data into both tables, detailing customer information and their respective orders. The Customers table holds customer details while the Orders table tracks orders linked to customers via foreign keys.

Uploaded by

koulibalyhamam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Lec 39 SQL Create Table

The document contains SQL commands to create two tables: Customers and Orders, with specified fields and relationships. It includes the insertion of sample data into both tables, detailing customer information and their respective orders. The Customers table holds customer details while the Orders table tracks orders linked to customers via foreign keys.

Uploaded by

koulibalyhamam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

CREATE TABLE Customers (

customer_id INT PRIMARY KEY,


customer_name VARCHAR(100),
email VARCHAR(100)
);

CREATE TABLE Orders (


order_id INT PRIMARY KEY,
customer_id INT,
order_date DATE,
amount DECIMAL(10, 2),
FOREIGN KEY (customer_id) REFERENCES Customers(customer_id)
);

-- Insert data into Customers table


INSERT INTO Customers (customer_id, customer_name, email)
VALUES
(1, 'Alice Smith', '[email protected]'),
(2, 'Bob Johnson', '[email protected]'),
(3, 'Charlie Brown', '[email protected]');

-- Insert data into Orders table


INSERT INTO Orders (order_id, customer_id, order_date, amount)
VALUES
(101, 1, '2024-07-15', 250.00),
(102, 1, '2024-08-05', 300.00),
(103, 2, '2024-08-10', 150.00),
(104, 3, '2024-06-25', 100.00);

You might also like