MySQL Statements By Using the Command Prompt

Introduction

MySQL – A Database Management System which is accompanied with PHP. MySQL is supported by the Oracle Corporation.

The Data in the MySQL Database values are stored in the Database Table.

Table – It is a collection of related data with a number of columns and rows by accessing two or more table values using primary key and foreign keys.

Create Database

Following is the way we are going to create a database in MySQL using the command prompt.

Syntax:

Create database database_name;

Command Prompt – Start -> cmd.exe and press enter to open command prompt.

Navigate MySQL using the following statements in command prompt.

C:\Users\Admin>cd/
C:\>cd ProgramData
C:\ProgramData>cd MySQL
C:\ProgramData\MySQL>cd "MySQL Server 5.1"
C:\ProgramData\MySQL\MySQL Server 5.1>cd data
C:\ProgramData\MySQL\MySQL Server 5.1\data>mysql -u root -p
Enter password: ************


Create Database: After navigation to MySQL we are going to create a Database in the name of Pet.

mysql> create database Pet;

Query OK, 1 row affected (0.05 sec)

Create Database

Create Table

Syntax:

Create table table_name;

Query:

Create Table

Here we are using a primary key as detailed. If we want to access the two or more tables this primary key is used and it act as a foreign key of another table. The primary key value is always not null and it should be an auto increment value;

Alter Table:

Syntax:

Alter table table_name column_name;

Alter Table
Modify Table:

Syntax:

Alter table table_name modify column_name data_type;

Modify Table

Add values to Table:

Syntax:

Insert into table_name(fieldname) values ( field_value);

Add values to Table

If field value is string it means use ‘’ or digit means use ‘ ‘;

Example: tommy” is a string value so we used “ ” and ‘3’ is a digit so we used ‘ ‘;

Ebook Download
View all
Learn
View all