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

Document Without First 12 Pages

The document provides SQL syntax for various database operations including adding and deleting attributes from tables, counting rows, renaming tables, and setting primary keys. It also includes examples of inserting data, updating records, and querying for specific conditions. Additionally, it outlines the creation of a relational database schema for a Minor Project with specified relations.

Uploaded by

Krishna
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 views14 pages

Document Without First 12 Pages

The document provides SQL syntax for various database operations including adding and deleting attributes from tables, counting rows, renaming tables, and setting primary keys. It also includes examples of inserting data, updating records, and querying for specific conditions. Additionally, it outlines the creation of a relational database schema for a Minor Project with specified relations.

Uploaded by

Krishna
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/ 14

Que.) Syntax to add an attribute in the table.

Alter table table_name (attribute name attribute type);

Que.) Syntax to delete any attribute from table


Alter table table name drop column attribute
name;Que.) General syntax to remove any table.
Drop table table name;
Que.) General syntax to remove database.
Drop database database name;

Que.) Write down the general syntax to count the no.


of rows in a table.

Ans.) select count(*) from table name;


Que.) Specific syntax.Que.) General syntax to rename a
given table.

Ans.) alter table old name rename new name;


Que.) Specific syntax.
Que.) Write down the syntax to eliminate those details
where address is Mathura.

Ans.) delete from table where condition;


Que.) Delete all the data from table.
Que: suppose you're given a table student with
attribute student id, student name. You're required to
make student id a primary key.
Ans: alter table ‘table name’ modify id int primary key;

Que: Change the default value of id attribute to not


null.
Ans: alter table ‘table name’ modify id int not null;

Que: To set any attribute as a primary key during


creation of tables.
Ans: create table ‘table name’ (id int not null primary,
name char (30))

Que: Change the name and hobby of student whose


roll number is 101.
Ans:
Name change to GLA
Hobby changes to cooking
UPDATE ‘table name’
SET name = 'GLA', hobby = 'cooking'
WHERE id = 101;

Que: How to apply the check constant.


Ans: check constant
How: We can prevent duplicity in student id.
Ans: We can use auto increment
Create table student (id int primary key auto
increment);

Que: Create a table named as result with attribute id


name and marks and write down the queries ton
display average marks of students.

Ans:
INSERT INTO result (id, name, marks) VALUES
(1, 'Abhinav', 85),
(2, 'Baawe', 90),
(3, 'Chaman', 78),
(4, 'Dudul', 88),
(5, 'Evengeriiy', 95);

SELECT AVG (marks) AS average marks FROM result;

Que: print maximum marks.


Ans: SELECT MAX(marks) AS ‘max_marks’ FROM result;
Que: Print minimum marks.
Ans: SELECT MIN (marks) AS ‘min_marks FROM result;

INSERT INTO GROUP (Group_code, Roll_no) VALUES


(400, 101), (401, 103), (402, 102), (403, 104), (404,
105);

Que: Tell me the roll number of students whose name


is not given in data / table.
Ans: select ID from student where Name is null.
Que: Display details of students who lies in range
between.
Ans: select * from student where marks between 60
and 100;
Que: Display the complete details of those students
whose marks is 75,85,95.
Que:

Que: select name where subject is database.


Que: select name where subject is either DE,Python or
database.
SELECT name, subject

FROM result

WHERE subject = 'DE' OR subject = 'Python' OR subject = 'Database';

Que: show desc entries:


Ques.) To create a relational database schema for a
Minor_Project, described by the following relations.
STUDENT (Roll_no, Name, Semester, Degree,
Contact_no, Email_id, Guide_no) GUIDE (Guide_name,
Guide_no, Guide_research_domain, Email_id) PROJECT
(Project_no, Project_title, Project_area, Start_dt,
Guide_no) GROUP (Group_code, Roll_no)
PROJECT_GROUP (Group_code, Project_no,
No_of_students).

You might also like