0% found this document useful (0 votes)
22 views

Practical_10_SQL

Practical

Uploaded by

parva7926
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Practical_10_SQL

Practical

Uploaded by

parva7926
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical 10: SQL Table and Queries

Table Description

| Column Name | Data Type | Description |

|---------------|-----------------|---------------------------|

| Customer_id | Int (Primary Key) | Unique identifier for each customer. |

| Firstname | Varchar(30) | First name of the customer. |

| Lastname | Varchar(30) | Last name of the customer. |

| Age | Int | Age of the customer. |

| City | Varchar(20) | City of residence. |

| Email_id | Varchar(20) | Email address. |

| Contactno | Varchar(30) | Contact number. |

SQL Queries

Create the table:

CREATE TABLE Customer (

Customer_id INT PRIMARY KEY,

Firstname VARCHAR(30),

Lastname VARCHAR(30),

Age INT,

City VARCHAR(20),

Email_id VARCHAR(20),

Contactno VARCHAR(30)

);
Insert values:

INSERT INTO Customer (Customer_id, Firstname, Lastname, Age, City, Email_id,

Contactno)

VALUES (1, 'John', 'Doe', 35, 'Mumbai', '[email protected]', '9876543210'),

(2, 'Jane', 'Smith', 28, 'Delhi', '[email protected]', '8765432109'),

(3, 'Aarav', 'Sharma', 40, 'Mumbai', '[email protected]',

'7654321098'),

(4, 'Mira', 'Verma', 25, 'Pune', '[email protected]', '6543210987'),

(5, 'Anya', 'Roy', 32, 'Delhi', '[email protected]', '5432109876');

Retrieve all records:

SELECT * FROM Customer;

Retrieve firstname, lastname, and city:

SELECT Firstname, Lastname, City FROM Customer;

Arrange names by age (ascending):

SELECT * FROM Customer ORDER BY Age ASC;

Retrieve customers from Mumbai:

SELECT * FROM Customer WHERE City = 'Mumbai';

Retrieve customers older than 30 years:

SELECT * FROM Customer WHERE Age > 30;

Retrieve customers whose name ends with 'a':


SELECT * FROM Customer WHERE Firstname LIKE '%a';

Delete customers from Delhi:

DELETE FROM Customer WHERE City = 'Delhi';

Create a form to display all customer information:

Use any database management software (e.g., MS Access, MySQL Workbench) to create a

form.

Steps:

1. Open the software and connect to the database.

2. Navigate to the 'Forms' section and select 'Create Form'.

3. Select the 'Customer' table as the data source.

4. Drag and drop fields onto the form layout as needed.

5. Save and preview the form.

You might also like