Question

Change table structure (add,edit,remove column of a table)at runtime

i. Add a column address in the EMP_SELECTION table.
ii. Execute SQL INSERT statement to create a record into EMP_SELECTION table
iii. run the query to updates all the records having GENDER as 'M', and increase
AGE of all the males by one year.
iv. Delete all the records from EMP_SELECTION Table where AGE is less than 18.

13 Sep 2024
Answer :
Word Count : 942

### Managing Table Structure and Data Operations in SQL and Python/C Lab

1. Changing Table Structure at Runtime

In SQL, changing the structure of a table, such as adding, editing, or removing columns, is typically done using `ALTER TABLE` statements. Below is how you can manage these operations.

#### i. Add a Column to the Table

To add a new column named `address` to the existing `EMP_SELECTION` table, use the following SQL statement:

```sql
ALTER TABLE EMP_SELECTION
ADD COLUMN address VARCHAR(255);
```

In this statement:
- `ALTER TABLE EMP_SELECTION`: Specifies the table to modify.
- `ADD COLUMN address VARCHAR(255)`: Adds a new column named `address` with a data type of `VARCHAR` and a maximum length of 255 characters.

#### ii. Execute SQL INSERT Statement to Create a Record

To insert a new record into the `EMP_SELECTION` table, use the `INSERT INTO` statement. For example, if you want to add a record with specific values, the SQL statement might look like this:

```sql
INSERT INTO EMP_SELECTION (id, name, gender, age, address)
VALUES (1, 'John Doe', 'M', 30, '123 Elm Street');
```

In this statement:
- `INSERT INTO EMP_SELECTION (id, name, gender, age, address)`: Specifies the table and columns where the new data will be inserted.
- `VALUES (1, 'John Doe', 'M', 30, '123 Elm Street')`: Provides the values for each column in the specified order.

#### iii. Update Records

To update all records where `GENDER` is 'M' and increase their `AGE` by one year, use the following SQL statement:

```sql
UPDATE EMP_SELECTION
SET age = age + 1
WHERE gender = 'M';
```

In this statement:
- `UPDATE EMP_SELECTION`: Specifies the table to update.
- `SET age = age + 1`: Updates the `age` column by incrementing it by one.
- `WHERE gender = 'M'`: Applies the update only to records where the `gender` is 'M'.

#### iv. Delete Records

To delete all records from the `EMP_SELECTION` table where `AGE` is less than

_________ __________ ________ __________ _______ _________ __________ __________ ____ __________.
____ _________ _________ __________ _______.
_________ ____ _____ __________ _________ _________ ___ ____ _______ ____ ______ ______.
_____ _________ _______ _________ ________ _______ ________.
_______ _____ _______ ___ ___ ____ ________ __________ ____ ___ ______.
__________ _______ ________ __________ ________ _______ ______ _______ ______ _______ ______ ________.
____ ______ ___ _____ _____ _________ _______ _________ ____ _________ __________ ______.
____ _________ _________ ________ __________ ___ _____ _______.
______ ______ ____ __________ ____ _________ ____ _______ __________ ______ ________.
_________ _________ _____ ________ _____.
________ ________ __________ ______ _____ ______ ______.
________ ________ ______ _____ __________ ____ __________.
___ ____ ________ ____ ________ _____.
__________ __________ ____ __________ _____ ______ _______ ______ ___ ___.
________ ___ ____ ________ __________ ___ ____ ________ _____.
____ __________ ____ ___ ______ _______ _______ ________ __________ _________ ___.
______ _____ _______ ______ ______ _______ ________.
__________ __________ __________ ________ _________.
__________ ____ _________ _________ ________ ____ ______ ___ ________ ____.
____ ________ ____ ______ __________ ___ ___ ______ _______ ________ ___ _________.
___ ______ ___ _________ ______ ___ ___ _____ ______ __________ ________.
________ __________ _____ ______ __________ ____ _______ ___.
____ _______ _____ ___ ___ _________ _______ ___ _______ ____.
_________ __________ ________ __________ _______ _____ ________ _________ _____ _______.
__________ _____ _______ __________ ______ ____ ___.
___ ___ ____ ________ _____ ____.
_________ _____ _________ ________ _______ ______.
_______ ___ ______ ___ ___ __________.
__________ ___ _____ __________ __________ ________ ____ ________ ______ ________.
_____ ________ ____ ____ __________ __________ _________ _______ ___.
_____ ___ _______ ___ ____ _________ _______ ____ __________ _____ ________.
____ _____ _____ _______ ____ _______ ______ ____ _______.
________ __________ __________ __________ __________ __________ ____ ________.
________ ____ ____ _________ _________ _____ ____ ________ __________ ___ ________ ___.
________ _______ _______ ______ ______ ______ ___ _____ __________.
________ ___ _________ __________ __________ ___ __________ ______ _____ ______ ___ _______.
___ _______ ______ ________ _______ ___ __________ ___ ____ _____ ____ __________.
________ ________ ______ ________ __________ _________ _____ _________.
____ ________ ___ ____ _______ _____ __________ __________ ___ ________ _______ ____.
_____ _______ _______ ______ __________ _______ ____ _________ ________ __________ ________.
___ __________ ___ _____ _____ _______ ________.
_______ _______ _________ ___ _________ ______ ______ ____ __________ ________ ___ _______.
_______ __________ ___ ________ ________ _____ ______ _______.
____ _______ ____ _______ ___ _______ _____ _________ ___ ___ ____.
___ _________ _______ _______ ________ _________ _____ ______.
_____ __________ _________ _____ _________.
__________ ________ _______ ____ ____ ___ _______ _________ ______ ______ _____ _________.
_____ _________ _______ ___ ____ ______ __________ _______ ___ ___.
____ _________ __________ ____ _________ ______ __________ _______ _________ ___ _____ ________.
_____ _____ _______ _________ _______ ________ _____ __________ ________ ____.
_______ ______ ___ _________ ____ ___ _______.
_____ ____ _______ __________ _____ ___ ___ _______.
_____ _________ ________ _________ __________ _____ ___ _________ _________ _________ ______ __________.
________ _______ ________ ________ ________ ________ __________ ____.
_______ __________ _________ __________ _______ ____ _________ ________ _______ ___ ____.
_____ ________ ___ __________ ______ ____ ______ __________ _______ ____ _________.
_____ _______ _____ _______ _____ ____.
__________ _______ _____ ______ ______ ___ ________ ________ ___ ______ ___.
________ ______ __________ ____ __________ __________ _______ __________ ________ ______ ____.
____ ______ ________ _____ __________ _________ _____ ____ _________.
___ ______ ____ ___ _______ _____ ______ ___ ________ ____ ______ ________.
______ ______ ________ ___ ____ _________ ______ _______.
_______ ______ __________ _______ _________ _______ ______ _______ _______ ______.
_____ ___ __________ ______ __________ __________ ________ ______ ______ __________.
__________ _______ ______ ___ _______ ______ ___.
______ __________ _________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCSL 205 2024 - Change table structure (add,edit,remove column of a table)at runtime | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→