260 likes | 518 Views
DATABASE MANAGEMENT SYSTEMS -- (ITCS 385). Mrs. Basma Alsadiq balsadiq@itc.uob.bh S40-1060. Database. Database is a collection of records. It is an organized collection of information. There are many types of database. Relational Database Management System. SQL.
E N D
DATABASE MANAGEMENT SYSTEMS -- (ITCS 385) Mrs. Basma Alsadiq balsadiq@itc.uob.bh S40-1060
Database • Database is a collection of records. • It is an organized collection of information. • There are many types of database.
SQL • Structured Query Language (SQL) is the language used to manipulate relational database
Database Queries • Structured Query Language (SQL) • Standard query language for relational databases • Query: command to perform operation on database object • Create • Modify • View • Delete
SQL Command Types • Data Definition Language (DDL) • Used to create and modify the structure of database objects • Data Manipulation Language (DML) • Used to insert, update, delete, and view database data
DDL Commands Used to create and modify the structure of database objects CREATE ALTER DROP DDL commands execute as soon as they are issued, and do not need to be explicitly saved
DML Commands Used to insert, view, and modify database data INSERT UPDATE DELETE SELECT DML commands need to be explicitly saved or rolled back COMMIT ROLLBACK Transaction control commands
Database Objects • An Oracle database consists of multiple user accounts • Each user account owns database objects • Tables • Views • Stored programs • Etc.
SQL*Plus • is a client terminal software allowing users to interact with Oracle server to manipulate data and data structures.
Create tables Creating tables is the first step in making your own database, and it follows the syntax: CREATE TABLE tablename( Column1 datatype(size), Column2 datatype(size), ….. );
Create tables (Example) CREATE TABLE student( ID Number(8), Name Varchar(15), GPA Decimal(3,2), Major Varchar(5), DOB Date);
If a table in the database is not needed any longer , then we can delete it using DROP TABLE command Example: Drop TABLE employee Drop Tables Command
Adding Columns Using ALTER TABLE command Syntax: ALTER TABLE <table_name> ADD <column_name> <datatype>(size)
Modify Columns Using ALTER TABLE command Syntax: ALTER TABLE <table_name> Modify <column_name> <datatype>(size)
Drop Columns Using ALTER TABLE command Syntax: ALTER TABLE <table_name> DROP COLUMN <column_name>;
Changing the name of a table • To change the name of a table, use the following statement. • Syntax: ALTER TABLE <table_name> rename to <new-name>
Changing the name of a column • To change the name of a table column, use RENAME statement. • Syntax: ALTER TABLE <table_name> rename column <old-name> to <new-name>