You are on page 1of 3

Installing XAMPP>

https://www.youtube.com/watch?v=h6DEDm7C37A
Creating Database and adding Table in cmd>
https://www.youtube.com/watch?v=FAXhXI2Gxdc

DATABASE FUNDAMENTALS
PRACTICE EXERCISE: DATABASE DESIGN USING COMMAND PROMPT

Objectives
Students should be able to:
1. Learn how to create a database using command prompt.
2. Execute the different commands to be used in creating database and tables.

Procedures
1. Install the SQLyog and MySQL Server in your computer unit.
2. Once you installed it, the MySQL 5.5 command line will be shown in Start program.
3. Go to the command prompt mentioned above.
4. It will require you to input your password:
Enter password: 1234 (depends on the password you registered during installation )
5. After you entered your password, the prompt below will be displayed.

6. To create a database:
Mysql> CREATE database sampledb;
Then press enter.

7. To show all the databases present in the server:


Mysql> SHOW databases;
Then press enter.

8. To go to the created database, type:


Mysql> USE sampledb;
Then press enter.

9. To create table:
Mysql> CREATE table stud_info
(uid int(2) primary key not null,
Lname varchar(20) not null,
Fname varchar (20) not null,
Mi varchar(2),
Allowance double (7,2) not null,
Bday date not null);
Then press enter.

10. To view existing tables:


Show tables;
Then press enter.

11. To view the fields of a specific table:


Describe stud_info;
Then press enter.

12. To add another field:


Alter table stud_info
Add age int(2) not null;
Then press enter.

Describe stud_info; // to show added field in table

13. To rename a table:


Alter table stud_info
Rename student_tab;
Then press enter.
Show tables; //to check the changes in table name
14. To drop a table field:
Alter table student_tab
Drop mi;
Then press enter.

Describe student_tab; // to show changes in table with deleted field

15. To drop a table:


Drop table student_tab;
Then press enter.

16. To drop database:


Drop database sampleDB;
Then press enter.

You might also like