0% found this document useful (0 votes)
9 views3 pages

Name 1

The document outlines SQL commands for creating and managing a customer table in a database. It includes commands for inserting data, altering the table structure, and renaming the table. Additionally, it demonstrates how to drop the table after performing various operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Name 1

The document outlines SQL commands for creating and managing a customer table in a database. It includes commands for inserting data, altering the table structure, and renaming the table. Additionally, it demonstrates how to drop the table after performing various operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name:ghada mohamed mostafa

ID:200047779

CREATE TABLE customer (


Customer_ID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(50),
Nationality VARCHAR(50) DEFAULT 'Egyptian',
Zip INT CHECK (Zip > 0),
Email VARCHAR(100)
);

INSERT INTO customer (Name, Nationality, Zip, Email)


VALUES ('James', 'Egyptian', 98310, '[email protected]'),
('Kate', 'Palestinian', 64068, '[email protected]'),
('Rex', 'Libyan', 59701, '[email protected]');

SELECT * FROM customer;

ALTER TABLE customer RENAME COLUMN Name TO First_Name;


DESCRIBE customer;

ALTER TABLE customer ADD Last_Name VARCHAR(50);

ALTER TABLE customer ADD CONSTRAINT unique_lastname UNIQUE (Last_Name);

ALTER TABLE customer DROP INDEX unique_lastname;

ALTER TABLE customer DROP COLUMN Zip;

RENAME TABLE customer TO CUST;

SHOW TABLES;

SELECT * FROM CUST;

DROP TABLE CUST;

You might also like