0% found this document useful (0 votes)
3 views

CreateTableExamples

This document provides examples of SQL commands for creating databases, specifically focusing on creating tables for Employees and Departments. It includes examples of inserting, deleting, and updating rows of data within the Departments table. The document serves as a practical guide for SQL fundamentals related to database management.

Uploaded by

[smo] Monkeyy-3
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CreateTableExamples

This document provides examples of SQL commands for creating databases, specifically focusing on creating tables for Employees and Departments. It includes examples of inserting, deleting, and updating rows of data within the Departments table. The document serves as a practical guide for SQL fundamentals related to database management.

Uploaded by

[smo] Monkeyy-3
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

CIST 1220 – SQL Fundamentals

Chapter 3 Creating Databases

Examples

Create Table Examples


Create Table Employees
(empid char(11) not null primary key,
firstName varchar(30) not null,
lastName varchar(30) not null,
address varchar(30) not null,
deptid char(4) null,
salary numeric null);

Create Table Departments


(deptid char(4) not null primary key,
name varchar(30) not null,
location varchar(30) not null,
manager char(11) null);

INSERT Examples – Insert 1 new row of data


Insert into Departments
values('ACCT', 'Accounting Department', 'Dallas, TX', '44551341889');

Insert into Departments(deptid, name, location)


values('MKTG', 'Marketing Department', 'Dallas, TX');

Insert into Departments(deptid, name, location)


values('IT', 'Information Technology Dept', 'Dallas, TX');

DELETE Example – Delete 1 or more rows of data


Delete from Departments
where deptid='MKTG';

UPDATE Example – Update 1 or more rows of data


Update Departments
set manager='886632319'
where deptid='IT';

You might also like