marventures / sql-ddl-dml-dql

Creating a simple College Database using SQL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL BASICS (DDL, DML, DQL)

  • Creating simple college database using SQL.

Table of contents

Overview

Screenshot

image

Links

My process

Built with

What I learned

  • Use Data Definition Language (DDL) subset of SQL to CREATE, ALTER OR DROP Database / Table.
  • a) CREATE statement
  • b) ALTER statement
  • Use Data Manipulation Language (DML) subset of SQL to POPULATE (INSERT), UPDATE, DELETE records from a Table.
  • a) UPDATE statement
  • b) DELETE statement
  • Use Data Query Language (DQL) subset of SQL to SELECT/ QUERY records from a Table.
  • a) SELECT statement
  • Add Primary key to a relational database

Here is a code snippet:

INSERT INTO student_tbl(ID, first_name, last_name, home_address, college_address, contact_number, department)
VALUES
(1, "John", "Murphy", "111 Park Street", "Stafford Building", "7654567632", "science"),
(2, "Sandra", "Hauge", "256 Stafford Street", "Stafford Building", "7634567652", "science"),
(3, "Jerry", "Millar", "222 Green Gardens", "Stafford Building", "7623951287", "science"),
(4, "Heather", "Dawson", "255 Lincoln Street", "Grand Building", "7629845645", "enginerring"),
(5, "Ryan", "Egan", "300 Grand Avenue", "Grand Building", "7649237645", "enginerring");

ALTER TABLE student_tbl
ADD PRIMARY KEY (ID);

UPDATE student_tbl
SET home_address = "234 Park Avenue", contact_number = "2345556767"
WHERE ID = 3;

UPDATE student_tbl
SET department = "engineering"
WHERE college_address = "Grand Building";

DELETE FROM student_tbl
WHERE ID = 3;

Useful resources

  • w3schools - This helped me for using SQL syntax.
  • w3school - This helped me for adding primary key to a database.

Author

About

Creating a simple College Database using SQL.