0% found this document useful (0 votes)
49 views3 pages

DDL, DML, DCL Assignment

Ddl dml dcl assignment

Uploaded by

Orginx logo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views3 pages

DDL, DML, DCL Assignment

Ddl dml dcl assignment

Uploaded by

Orginx logo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DDL, DML, Assignment

1. Using ER-Diagram to design an efficient Data Model by Customers, Product and Customer_Address Entities.

2. Transform the previously designed ER data model into RDBMS tabular structure along with its schema
creation.

create database assignments;


use assignments;

#creating customer table


create table customer (
email varchar (30) primary key,
name varchar (30) not null,
product_id int (10) references product (product_id),
z_code int (10) references address(zip_code)
);
alter table customer add contact varchar (15);

#creating product table


create table product (
product_id int (10) primary key,
product_name varchar (30) not null,
price float(10, 2) not null
);

#Creating customer_address table


create table customer_address(
zip_code int (10),
street_address varchar (45),
DDL, DML, Assignment
city varchar (15),
state varchar (20),
primary key (zip_code));

# Adding Country column in the customer_address table


alter table customer_address add country varchar (30);

#Inserting values to the tables

-- Inserting values in the Customer table


insert into customer (email, name, contact) values ("[email protected]", "Venkat", 7373456800);
insert into customer (email, name, contact) values ("[email protected]", "srikanth", 7373456801);
insert into customer (email, name, contact) values ("[email protected]", "guna", 7373456855);

-- Inserting values in the product table


insert into product values (1234,"Table", 300.12);
insert into product values (3456,"Bench", 350.12);
insert into product values (5678,"sofa",400.12);

-- Inserting values in the customer_adress


insert into customer_address values (631304, "kamala vinayagar kovil steet", "singasamuthiram", "Tamil
nadu");
insert into customer_address values (63135, "kamala vinayagar kovil steet", "singasamuthiram", "Tamil
nadu");
insert into customer_address values (631306, "kamala vinayagar kovil steet", "singasamuthiram", "Tamil
nadu");

#Creating duplicate table from customer table.


create table customer_bkup select * from customer;

# Dropping column state from customer_address;


alter table customer_address drop column state;

#Rename the table 'Customer_Address' to 'Address'.


alter table customer_address rename to address;
DDL, DML, Assignment
3. Suppose 'Amit Jaiswal' is Hired as Database Developer in IBM, you working there as a DBA. Your
manager assigned a ticket to you to create a user account on behalf of Amit where his password is
expired at first login and he will be able to set his new password. Please write down the SQL query to
perform the same Task.

#Creating new user called with amit with passowrd expire in first login
create user 'amit'@'localhost' identified by 'Amit123' password expire;

#Creating two databases


create database uat;
create database prod;

#Assigning rights to the user Amit


grant select on prod.* to 'amit'@'localhost';
grant select, create , alter, drop, insert, update,delete on uat.* to 'amit'@'localhost';

#Revoking Privileges from user


revoke select on prod.* from 'amit'@'localhost';
revoke select, update, drop, insert, delete , alter , create on uat.* from 'amit'@'localhost';

You might also like