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

SQL Database Operations for Table Management

The document outlines a series of SQL commands for creating and managing a database named 'Priya'. It includes creating a table, altering its structure, inserting and selecting data, updating records, and deleting entries. Additionally, it demonstrates how to rename and drop columns and tables within the database.

Uploaded by

shanmugapriya
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)
4 views1 page

SQL Database Operations for Table Management

The document outlines a series of SQL commands for creating and managing a database named 'Priya'. It includes creating a table, altering its structure, inserting and selecting data, updating records, and deleting entries. Additionally, it demonstrates how to rename and drop columns and tables within the database.

Uploaded by

shanmugapriya
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 Database Priya;

Show Databases;

Use Priya;

Create Table test (


Name VARCHAR(30),
Id INT Primary Key,
Grade varchar(10));

Show Tables;

Alter table test add Section Char(10);


describe test;

Insert into test (Name,Id) Values ('Priya',100),('Riya',101);


Select * from test;
Select Name, Id from test;

Insert into test values('Priya',101,8,'A');

Insert into test values('Pragya',104,8,'A'),('Sarah',105,8,'B'),('Lizy',106,8,'A');

Select * from test;


Select * from test where Name like 'P%';
Select * from test where Name not like 'P%';

Select Name, Id*3 from test;

Select * from test where Name like '%a' and Name like 'P%';

Select * from test where Name like '%a' or Name like 'P%';

Select * from test where Id>103;

Select * from test where Section ='A';

Update test set Id=305 where Name ='Riya';

Select * from test;

delete from test where Name like 'R%';


Select * from test;

Alter table test rename column Section to Sec;

describe test;

Alter table test modify Sec varchar(30);


describe test;

Alter table test drop column Sec;


describe test;

drop table test;

describe test;

You might also like