0% found this document useful (0 votes)
18 views2 pages

SQL Program for ENROLLS_IN Table

The document outlines a complete SQL program for managing the ENROLLS_IN table, including steps for creating the table, altering its structure, inserting records, and performing various queries. It details commands for updating, deleting specific records, and dropping the table. Additionally, it includes an interactive insertion method using variables.

Uploaded by

nivimk12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

SQL Program for ENROLLS_IN Table

The document outlines a complete SQL program for managing the ENROLLS_IN table, including steps for creating the table, altering its structure, inserting records, and performing various queries. It details commands for updating, deleting specific records, and dropping the table. Additionally, it includes an interactive insertion method using variables.

Uploaded by

nivimk12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Complete SQL Program for ENROLLS_IN

Table
Step 1: Create the Table

CREATE TABLE ENROLLS_IN (


Reg_no CHAR(9),
Crs_id CHAR(8),
Rdate DATE,
Treg TIMESTAMP(0),
PRIMARY KEY (Reg_no, Crs_id)
);

Step 2: Alter Table – Add a Column

ALTER TABLE ENROLLS_IN


ADD Marks NUMBER(3);

Step 3: Alter Table – Modify a Column

ALTER TABLE ENROLLS_IN


MODIFY Marks NUMBER(5,2);

Step 4: Insert Records

INSERT INTO ENROLLS_IN


VALUES ('25MCA0137', 'CS101', TO_DATE('2025-07-10','YYYY-MM-DD'), SYSTIMESTAMP,
85.5);

INSERT INTO ENROLLS_IN


VALUES ('25MCA0138', 'CS102', TO_DATE('2025-07-11','YYYY-MM-DD'), SYSTIMESTAMP,
90.0);

Step 5: Interactive Insertion Using & Variables

INSERT INTO ENROLLS_IN


VALUES ('&Reg_no', '&Crs_id', TO_DATE('&Rdate','YYYY-MM-DD'), SYSTIMESTAMP,
&Marks);
Step 6: Display All Records

SELECT * FROM ENROLLS_IN;

Step 7: Select Specific Columns

SELECT Reg_no, Crs_id, Marks FROM ENROLLS_IN;

Step 8: Update a Record

UPDATE ENROLLS_IN
SET Marks = 95.0
WHERE Reg_no = '25MCA0137' AND Crs_id = 'CS101';

Step 9: Delete a Specific Record

DELETE FROM ENROLLS_IN


WHERE Reg_no = '25MCA0138' AND Crs_id = 'CS102';

Step 10: Delete All Records

DELETE FROM ENROLLS_IN;

Step 11: Drop the Table

DROP TABLE ENROLLS_IN;

Extra: Describe the Table Structure

DESC ENROLLS_IN;

You might also like