0% found this document useful (0 votes)
19 views4 pages

Creating A Database in Mariadb Prompt of Xampp Server

The document discusses how to create and manage databases and tables in MariaDB. It provides the steps to: 1. Create a database called "univ" using the "create database" command in MariaDB. 2. View existing databases using "show databases;" and select a database using "use <database_name>". 3. Important SQL commands for database management include create, alter, and drop for creating, modifying, and deleting tables.

Uploaded by

SCAS 305-15
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)
19 views4 pages

Creating A Database in Mariadb Prompt of Xampp Server

The document discusses how to create and manage databases and tables in MariaDB. It provides the steps to: 1. Create a database called "univ" using the "create database" command in MariaDB. 2. View existing databases using "show databases;" and select a database using "use <database_name>". 3. Important SQL commands for database management include create, alter, and drop for creating, modifying, and deleting tables.

Uploaded by

SCAS 305-15
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/ 4

Creating a database in mariadb prompt of Xampp server:

1. Start xampp control panel and start apache and mysql servers. Minimize this
window.

2. Open the windows command prompt

3. Change the directory to C:\Xampp\mysql\bin

4. Type the command mysql.exe -u root <space> ( after root leave a space for
password)

5. the prompt will be changed to mariadb(none)>: This shows that no database


is selected.

Important commands related to database:

1. Creating a database: create database <database_name>

MariaDB [(none)]> create database univ;

2. Viewing the existing databases: show databases;

3. To select any database: use <database_name>

MariaDB [(none)]> use univ;

4. To display the created in the database: show tables;


DDL

1. Create
1. Create
2. Create table as
2. Alter
1. Add (single column/ multiple column)
2. Add (After)
3. Modify(single column/multiple column)
4. Drop(column)
5. Change Column Name
6. Rename table
3. Drop
1. Drop (single table/multiple table/ temporary table)

1. Create

Syntax

CREATE TABLE table_name( column1 datatype [ NULL | NOT NULL ],column2


datatype [ NULL | NOT NULL ]);

Eg

Create table student(name varchar(20), regno integer(8), dob date);

CREATE TABLE AS

Syntax

CREATE TABLE new_table [ AS ] SELECT expressions FROM existing_tables


[WHERE conditions];

Eg

Create table stud as (select * from student);


2. Alter

Add (single column)

syntax

ALTER TABLE table_name ADD new_column_name column_definition [ FIRST |


AFTER column_name ];

Eg

Alter table student add age integer(3);

Add (multiple column)

syntax

ALTER TABLE table_name ADD new_column_name column_definition [ FIRST |


AFTER column_name ], ADD new_column_name column_definition[ FIRST |
AFTER column_name ];

Eg

ALTER TABLE student ADD last_name varchar(40) NOT NULL AFTER sid, ADD
address varchar(35) NULL AFTER last_name;

Add using after

Syntax

ALTER TABLE table_name ADD new_column_name column_definition [ FIRST |


AFTER column_name ];

Eg

Alter table student add last_name varchar(40) NOT NULL AFTER sid;

Modify

Syntax

ALTER TABLE table_name MODIFY column_name column_definition [ FIRST |


AFTER column_name ];

Eg

Alter table student modify name varchar(30);


Drop

Syntax

ALTER TABLE table_name DROP COLUMN column_name;

Eg

Alter table student drop age;

Change Column Name

Syntax

ALTER TABLE table_name CHANGE COLUMN old_name new_name


column_definition [ FIRST | AFTER column_name ]

Eg

ALTER TABLE student CHANGE COLUMN std_id sid integer(8) NOT NULL;

Rename table

Syntax

ALTER TABLE table_name RENAME TO new_table_name;

Eg

ALTER TABLE student RENAME TO stud;

3. Drop

Syntax

DROP TABLE table_name;

Eg

Drop table student;

Drop Multiple Tables

DROP TABLE customers, suppliers;

Drop Temporary Table

DROP TEMPORARY TABLE IF EXISTS customers;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy