Cassandra all programs

 1 question -Here's how you can perform these tasks in SQL:


### 1. Create the `Student_info` Table

```sql

CREATE TABLE Student_info (

    rollno INT PRIMARY KEY,

    studname VARCHAR(50),

    age INT,

    department VARCHAR(50),

    lastexampercent DECIMAL(5, 2)

);

```


### 2. Insert Records

```sql

INSERT INTO Student_info (rollno, studname, age, department, lastexampercent) VALUES

(1, 'John', 20, 'Computer Science', 85.5),

(2, 'Alice', 22, 'Mathematics', 90.0),

(3, 'Bob', 21, 'Physics', 78.5);

```


### 3. View Records of Students with Roll Numbers 1, 2, and 3

```sql

SELECT * FROM Student_info WHERE rollno IN (1, 2, 3);

```


### 4. Create an Index on the `studname` Column

```sql

CREATE INDEX idx_studname ON Student_info (studname);

```


### 5. Display the Records with a Limit of 2 Results

```sql

SELECT * FROM Student_info LIMIT 2;

```


### 6. Add a New Column `address` to the `Student_info` Table

```sql

ALTER TABLE Student_info

ADD address VARCHAR(100);

```


### 7. Update the `studname` Where `rollno = 1` to "Jonathan"

```sql

UPDATE Student_info

SET studname = 'Jonathan'

WHERE rollno = 1;

```


### 8. Delete the `lastexampercent` of the Student with `rollno = 2`

```sql

UPDATE Student_info

SET lastexampercent = NULL

WHERE rollno = 2;

```


### 9. Delete the Record of the Student with `rollno = 2` Entirely

```sql

DELETE FROM Student_info WHERE rollno = 2;

```


These SQL statements will perform all the specified tasks on the `Student_info` table.


2 questions - Here's how you can create the `project_details` table and write SQL statements for the specified operations:


### 1. Create the `project_details` Table

```sql

CREATE TABLE project_details (

    ProjectID INT PRIMARY KEY,

    ProjectName TEXT,

    StartDate DATE,

    EndDate DATE

);

```


### 2. Insert Data into the `project_details` Table

```sql

INSERT INTO project_details (ProjectID, ProjectName, StartDate, EndDate) VALUES

(101, 'Project A', '2024-01-15', '2024-06-30'),

(102, 'Project B', '2024-03-01', '2024-08-15'),

(103, 'Project C', '2024-04-20', '2024-09-10');

```


### 3. Update the `EndDate` of the Project with `ProjectID = 101` to '2024-07-10'

```sql

UPDATE project_details

SET EndDate = '2024-07-10'

WHERE ProjectID = 101;

```


### 4. Retrieve All Project Details from the `project_details` Table

```sql

SELECT * FROM project_details;

```


### 5. Delete the Project with `ProjectID = 102` from the Table

```sql

DELETE FROM project_details

WHERE ProjectID = 102;

```


### 6. Retrieve Project Details Where the `StartDate` Is After '2024-02-01'

```sql

SELECT * FROM project_details

WHERE StartDate > '2024-02-01';

```


3 questions - These SQL commands will create and manage the `project_details` table with the specified operations.


Here's how you can create the `user` table and write SQL statements for each of the specified operations:


### 1. Create the `user` Table

```sql

CREATE TABLE user (

    UserID INT PRIMARY KEY,

    UserName TEXT,

    Email TEXT,

    Phone TEXT

);

```


### 2. Insert Data into the `user` Table

```sql

INSERT INTO user (UserID, UserName, Email, Phone) VALUES

(1001, 'Alice', 'alice@mail.com', '123-456-7890'),

(1002, 'Bob', 'bob@mail.com', '234-567-8901'),

(1003, 'Charlie', 'charlie@mail.com', '345-678-9012');

```


### 3. Create an Index on the `Email` Column

```sql

CREATE INDEX idx_email ON user (Email);

```


### 4. Update the `Email` of the User with `UserID = 1002` to 'bob_new@mail.com'

```sql

UPDATE user

SET Email = 'bob_new@mail.com'

WHERE UserID = 1002;

```


### 5. Retrieve and Display All Records from the `user` Table

```sql

SELECT * FROM user;

```


### 6. Delete the User with `UserID = 1003` from the Table

```sql

DELETE FROM user

WHERE UserID = 1003;

```


These SQL commands will handle the `user` table creation and management with the required operations.



Comments

Popular posts from this blog

Mangodb games , movies