Lec2 Lab CSC371 Database Systems
Lec2 Lab CSC371 Database Systems
(LAB)
PREVIOUS LECTURE REVIEW
• Students should develop a Database System at the end of the term.
• SQL
• DBMS
• Microsoft SQL Server/ MySQL
• How to write a simple query
AGENDA
• Introduction to Microsoft SQL Server Express Edition
• Demonstration: How to write and execute SQL statements
MICROSOFT SQL SERVER EXPRESS
EDITION
• Microsoft SQL Server Management studio
• Database Engine
RESOURCES TO CONSULT AND
PRACTICE
• https://www.w3schools.com/sql/default.asp
• https://www.w3resource.com/sql-exercises/
DATABASE CREATION
• Syntax
• CREATE DATABASE databasename;
• Create database test
SQL CREATE TABLE STATEMENT
• Syntax
• CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
• CREATE TABLE Staff (
staffNo int,
fName varchar(255),
lName varchar(255),
position varchar(255),
gender char ,
DOB date,
salary money,
);
SQL INSERT INTO STATEMENT
• Syntax:
• INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
• insert into staff (staffNo, fName, lName , position, gender, DOB, salary)
values(123,'A','B', 'Manager', 'M','11-02-19', 12000)
THE SQL SELECT STATEMENT
• Syntax
• SELECT column1, column2, ...
FROM table_name;
• select staffNo, fName, lName , position, gender, DOB, salary from staff
• Select * from staff
SUMMARY
• How to open and write query.
• How to execute SQL statement.
• How create database.
• How to create table.
• How to insert data record into table.
• How to retrieve data from table.