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

SQL Student Table Operations Guide

Uploaded by

memegwf
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 views6 pages

SQL Student Table Operations Guide

Uploaded by

memegwf
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

Practical no.

20
Create a student table with
(StudentID,Name,Marks)as attributes where
“StudentID”is a primary key.
Source code:
Create table student
(StudentID varchar(3) primarykey,
Name char(25) notnull,
Marks int(3) check(Marks<45);

Practical no.21
Insert the details of the students in the above
table.
Source code:-
Insert into student
Value(121,Luna,85),(136,Alex,87),(134,
Alice,100),(85,Cami,45),(8,Billie,76);
Practical no.22
Delete the tha details of the student name
cami form the table.
Source code:-
Delete form student
Where Name like “cami”;

Practical no.23
Use select command to get the detail of the
student with Marks more then ‘50’.
Source code:-
Select *
from student
where Marks>50;
Practical no.24
Create a new table
“order”(OrderID,Cust_name,Order_date).By
joining this table customer(CustID,OrderID).
Source code:-
Select OrederID,Cust_name,Order_date,
Cust_name
Form order,customer
Where [Link]=[Link];

Practical no.25
Find MIN,MAX,SUM,AVG of Marks in table
student.
Source code:-
SelectMIN(Marks),MAX(Marks),SUM(Marks),
AVG(Marks)
From student;
Practical no.26
Find total number of student in the table
student.
Source code:-
Select count(StudentID)
From student;

Practical no.27
Write a query to order student ID in student
table in descending order of Marks.
Source code:-
Select*
From student
Order by marks ascending=”false”;
Practical no. 28
Edit the detail of the student using update.
Source code:-
Update student
Set Name=”Ben”
Set Marks=”86”
Where StudentID=136;

Practical no.29
Alter student table from the student table by
adding a new column.
Source code:-
Alter table student
Add coloum percentage varchar 3
notnull;
Practical no. 30
Delete the whole table.
Source code:-
Drop table student;

Common questions

Powered by AI

Practical no.22 involves deleting a student record based on a name match . This operation is critical for maintaining database quality by removing redundant, incorrect, or obsolete data, thus optimizing performance. However, inaccuracies in execution (e.g., incorrect syntax 'form' should be 'from') can lead to failed operations. Careful management of deletion operations is vital to maintaining the relevance and accuracy of stored data, ensuring the database reflects the current real-world situation .

The "student" table has several constraints: the 'StudentID' is defined as a primary key, ensuring uniqueness and preventing null values, which maintains entity integrity by uniquely identifying each student . The 'Name' column has a NOT NULL constraint making sure every student entry has an associated name, thus maintaining data completeness . The 'Marks' column has a CHECK constraint that restricts values to less than 45, ensuring that only valid marks are stored in the database, which could be a business rule to keep data consistent .

The query in Practical no.24 attempts to join 'order' and 'customer' tables on their OrderID field but contains syntax errors that affect its accuracy and completeness. The clause 'Cust_name Form order,customer' should be 'FROM order, customer'. Additionally, revising the table aliases can improve readability. For instance, it should read 'FROM order o, customer c WHERE o.OrderID = c.OrderID' . These corrections ensure the accurate execution of join operations, enabling valid relational data retrieval across linked tables, essential for comprehensive data analysis .

Practical no.21's insertion attempt contains syntax errors and logical issues. The use of 'Value' should be 'VALUES' in standard SQL syntax . Moreover, the specified marks exceed the CHECK constraint (max 45), raising data integrity issues. Correct insertion requires compliance with constraints: change marks like 85 to valid values and adjust the statement to 'INSERT INTO student (StudentID, Name, Marks) VALUES (…), …' ensuring that all values satisfy table constraints and maintain data integrity .

The SQL query in Practical no.27 is intended to order student entries by their marks in descending order by using the 'Order by' clause . However, the syntax needs correction: the clause 'Order by marks ascending='false'' should be corrected to 'Order by Marks DESC' to explicitly specify descending order. The incorrect syntax could lead to SQL errors or default behavior of ascending order .

Practical no.29 alters the "student" table by adding a new column named 'percentage' with a NOT NULL constraint . This change requires that all existing records in the table accommodate this new column, which could impact existing data if default values are not specified for this column upon its creation. Depending on the database system, this might necessitate updating pre-existing records with a valid percentage to maintain integrity, potentially complicating data consistency if not managed properly .

The query in Practical no.28 aims to update the record for the student with StudentID 136 by changing the student's name to 'Ben' and marks to '86' . However, there is a syntax error: the 'SET' clause is repeated incorrectly. Correct SQL syntax should be 'UPDATE student SET Name='Ben', Marks=86 WHERE StudentID=136'. These errors could prevent the query from executing successfully, highlighting the importance of understanding SQL syntax for effective database manipulation .

Practical no.30 involves dropping the entire "student" table, a drastic operation that results in the complete loss of all data within that table . Without precautions like data backup, this operation can lead to irreversible data loss, which is critical in environments where data needs to be preserved for future reference or auditing. Executing a DROP TABLE command should be accompanied by thorough verification, benefits-vs-risks assessment, and typically be followed by a planned backup recovery mechanism, especially in production environments .

Statistical analysis in databases, such as calculating MIN, MAX, SUM, and AVG of student marks, is vital in educational settings for benchmarking purposes . These metrics allow educators to understand performance distributions, identify outliers, set academic targets, and allocate resources effectively. Such analyses provide insights into academic outcomes, facilitating informed decision-making in curricula adjustments, and individualized student support strategies .

Practical no.23 uses the SQL SELECT statement with a WHERE clause to filter and retrieve records of students whose marks are greater than 50 . This operation is critical in educational assessments to identify students who have exceeded a performance benchmark, allowing educators to focus interventions or enhancements accordingly. Such queries can assist in merit-based evaluations or in identifying candidates for advanced programs, thereby influencing educational planning and policy .

You might also like