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

Creating Database in Console

This document provides steps for creating a database and tables using the MySQL console in XAMPP. It includes: 1. Opening XAMPP and starting the Apache and MySQL services. 2. Opening the command prompt to access MySQL with the "mysql -u root -p" command. 3. Creating a database called "Student" using the "CREATE DATABASE" command and accessing it by selecting it with "USE Student". 4. Creating a table called "StudentInfo" with columns for student data like name, age, and address using the "CREATE TABLE" command.

Uploaded by

Haruka Nanase
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)
98 views

Creating Database in Console

This document provides steps for creating a database and tables using the MySQL console in XAMPP. It includes: 1. Opening XAMPP and starting the Apache and MySQL services. 2. Opening the command prompt to access MySQL with the "mysql -u root -p" command. 3. Creating a database called "Student" using the "CREATE DATABASE" command and accessing it by selecting it with "USE Student". 4. Creating a table called "StudentInfo" with columns for student data like name, age, and address using the "CREATE TABLE" command.

Uploaded by

Haruka Nanase
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/ 10

1

TABLE OF FUCKING CONTENTS

OPENING OF XAAMPP AND COMMAND PROMPT -------------------- 2


CREATING DATABASAE -------------------- 3
CREATING TABLES -------------------- 4
ADDING NEW COLUMN TO THE EXISTING TABLE -------------------- 5
CHANGING COLUMN DATATYPE -------------------- 6
RENAMING COLUMN -------------------- 7
OPENING OF XAAMPP AND COMMAND PROMPT -------------------- 2
OPENING OF XAAMPP AND COMMAND PROMPT -------------------- 2
OPENING OF XAAMPP AND COMMAND PROMPT -------------------- 2
OPENING OF XAAMPP AND COMMAND PROMPT -------------------- 2
2

STEP BY STEP GUIDE ON HOW TO CREATE DATABASE USING CONSOLE

1. Make sure to open XAMPP and start APACHE AND MYSQL

2. Open Command Prompt


3

3. To create database, you need to access it first. To do that, you need to


type “mysql -u root -p” in the cmd, -u stands for “username” and -p for
“password.” And hit enter.

4. CREATING DATABASE: The syntax to create database is

CREATE DATABASE database_name;

For example: I want to create a database named Student. The syntax now is
CREATE DATABASE Student;

5. To show the database you created, type SHOW DATABASES;


4

6. To be able to add tables and columns to the database you created, we


need first to USE it.

Syntax: USE db_name;

Example: USE student;

Now, we can add tables and columns to our STUDENT database.

7. CREATING TABLES

Syntax: CREATE TABLE table_name(Column1 datatype1, Column2


datatype2, Column3 datatype3);

Example: CREATE TABLE StudentInfo(name VARCHAR(50), age INT,


address VARCHAR(35)):
5

ALTER COMMAND

8. ADDING NEW COLUMN TO THE EXISTING TABLE :

ADD keyword

Syntax: ALTER TABLE table_name ADD(Column_name datatype);

Example: ALTER TABLE StudentInfo ADD(Contact_Num INT, email


VARCHAR(50));

BEFORE

AFTER
6

9. MODIFY AN EXISTING COLUMN: For changing datatype

MODIFY keyword

Syntax: ALTER TABLE table_name modify column_name datatype;


Example: ALTER TABLE StudentInfo modify address VARCHAR(75);
7

10. RENAME A COLUMN: RENAME keyword

Syntax: ALTER TABLE table_name RENAME old_column_name TO new_column;


Example: ALTER TABLE StudentInfo RENAME address TO Location;

11. DELETING COLUMN: DROP KEYWORD


8
9
10

You might also like