0% found this document useful (0 votes)
27 views15 pages

Session 01

This document provides an overview of advanced database management systems and includes the following topics: 1. Creating, dropping, and selecting databases. 2. Creating, dropping, and modifying tables using commands like CREATE TABLE, DROP TABLE, ALTER TABLE, ADD COLUMN, and DROP COLUMN. 3. Defining primary and foreign keys. 4. Performing queries with SELECT and specifying conditions with WHERE, AND, OR and NOT. 5. Inserting, updating, and deleting data using INSERT, UPDATE, DELETE. It also covers user management topics like creating and dropping users, setting passwords, and viewing user information.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views15 pages

Session 01

This document provides an overview of advanced database management systems and includes the following topics: 1. Creating, dropping, and selecting databases. 2. Creating, dropping, and modifying tables using commands like CREATE TABLE, DROP TABLE, ALTER TABLE, ADD COLUMN, and DROP COLUMN. 3. Defining primary and foreign keys. 4. Performing queries with SELECT and specifying conditions with WHERE, AND, OR and NOT. 5. Inserting, updating, and deleting data using INSERT, UPDATE, DELETE. It also covers user management topics like creating and dropping users, setting passwords, and viewing user information.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Advanced Database

Management System

IT3223
1.
Introduction
⬡ CREATE DATABASE databasename;
⬡ Create database ADBMS;
⬡ DROP DATABASE databasename;
⬡ Drop database ADBMS;
⬡ Use databasename
⬡ Use mysql;

3
CREATE TABLE table_name (
column1 datatype,

“ column2 datatype,
column3 datatype,
....
);

CREATE TABLE Persons (


PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
DROP TABLE table_name; 4
ALTER TABLE
1. ADD Column
ALTER TABLE table_name
ADD column_name datatype;
2. DROP COLUMN
ALTER TABLE table_name
DROP COLUMN column_name;
3. MODIFY COLUMN
ALTER TABLE table_name
MODIFY COLUMN column_name
datatype;

5
Primary key
⬡ CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (ID)
);
⬡ ALTER TABLE Persons ADD PRIMARY KEY (ID);
⬡ ALTER TABLE Persons DROP PRIMARY KEY;
6
Foreign key
⬡ CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);
⬡ ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);

7
⬡ SELECT column1, column2, ...
FROM table_name;
⬡ SELECT column1, column2, ...
FROM table_name
WHERE condition;

8
⬡ AND Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
⬡ OR Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
⬡ NOT Syntax
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
9
It is possible to write the INSERT
INTO statement in two ways:
1. Specify both the column names and the values to be inserted:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

2. If you are adding values for all the columns of the table, you do not
need to specify the column names in the SQL query. However, make sure
the order of the values is in the same order as the columns in the table.
Here, the INSERT INTO syntax would be as follows:

INSERT INTO table_name


VALUES (value1, value2, value3, ...);

10
⬡ UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
⬡ DELETE FROM table_name WHERE condition;

11
2.Users
Create user & Drop user
⬡ create user '[username]'@'[host]' identified by
[password];
Ex:create user 'Admin1'@'localhost’ identified by '123';
To check
⬡ use mysql;
⬡ select user,host from user;
⬡ select user,host,password from user;
⬡ drop user [username]'@'[host] ;

13
Manage user
update user set user='student01' where user='student';
update user set host='localhost' where user='student01' and
host ='vau.jfn.ac.lk’;
set password for 'student01'@'localhost'=password('abcd');

14
Thank you!

15

You might also like