Skip to content

Instantly share code, notes, and snippets.

View rithask's full-sized avatar
:bowtie:
idk how to code

Rithas M K rithask

:bowtie:
idk how to code
View GitHub Profile
@rithask
rithask / docker-aliases.sh
Last active December 30, 2023 06:54
Docker aliases
#!/bin/bash
read -r -d '' aliases << EOM
alias dps="docker ps"
alias dcu="docker compose up -d"
alias dcd="docker compose down"
alias dcf="docker compose up -d --force-recreate"
alias dcl="docker compose logs -f"
alias dcp="docker compose pull"
@rithask
rithask / 10.sql
Last active November 16, 2023 02:34
KTU DBMS Lab
/*
AIM:
Given Student Report Database, in which student marks assessment is recorded. In such schema, create a trigger so that the total and average of specified marks is automatically inserted whenever a record is inserted.
Student
Sid name Subj1 Subj2 Subj3 Total Avg
*/
DELIMITER //
@rithask
rithask / 9.sql
Last active November 14, 2023 02:44
KTU DBMS Lab
/*
AIM:
Create a trigger to print the following messages when insert, delete or update operation is performed on students table mentioned in the previous experiment for each tuple that is inserted, deleted or updated. Assume that semester grades of s1 and s2 are stored in students table along with Roll number and name of students
Operation Action/Message
if name of student is updated updated to sname (sname is the revised name of the
particular student)
roll, grd_s1 or grd_s2 is updated inserting sname(sname is the entered name of the
particular student)
if a row/tuple is deleted deleting sname(sname is the name of the deleted student)
@rithask
rithask / 8.sql
Last active November 14, 2023 02:00
KTU S5 DBMS
/*
AIM:
Create a cursor that stores the details of students eligible for honours in roll number order. Assume that semester grades of s1 and s2 are stored in students table along with Roll number and name of students. A student is eligible for honors if the total grade for s1 and s2 is greater than 12. Print the highest grade obtained in the previous semesters for honors students using the cursor created.
*/
-- Create the table to store the student details.
CREATE TABLE students (
roll_number NUMBER,
name VARCHAR2(20),
s1 NUMBER,
@rithask
rithask / 7.sql
Last active November 7, 2023 02:49
PL/SQL to print electricity bill of the consumer
/*
AIM:
Write a PL/SQL program using cursor to print the electricity bill of the consumer (refer unit-charge table given below)
Unit consumed charge
1 100 5
101-300 7.5
301-500 15
>500 22.5
@rithask
rithask / 6.sql
Last active November 7, 2023 02:50
PL/SQL block to determines the category/type of customer after verifying their account balance
/*
AIM:
Create a pl/sql block for creating a function dc that determines the category/type of customer after verifying their account balance. The following are the categories category platinum(for account balance greater than 50k) , gold (account balance less than or equal to 50k but greater than 10k) ,silver(for account balance less than or equal to 10k). Assume necessary attributes in customer. Write a query to retrieve the details of customers along with customer category(using the created function dc)
*/
-- Create the function dc to determine the customer category
CREATE OR REPLACE FUNCTION dc(balance NUMBER)
RETURN VARCHAR2 IS
category VARCHAR2(20);
BEGIN
@rithask
rithask / 5.sql
Last active October 25, 2023 02:49
PL/SQL program to find average mark of students
/*
AIM:
Write a pl/sql block to find average mark of students in a class and print the marks;Print a message " Need improvement " if the class average is less than 40. At the bottom print today's date and day of the week (monday, tuesday etc.)
*/
DECLARE
-- Declare variables to store class average and student marks.
class_average NUMBER := 0;
total_students NUMBER := 0;
student_average NUMBER := 0;