Posted by Firmware Tech on Saturday, September 22, 2018
Step By Step Create a MySQL Database Via Command Line on Windows.
Create a MySQL Database. This guide under will show you the way to Create a MySQL Database Via Command Line on Windows. It's smooth to create a database, we have to know a way to enter SQL statements. By growing a database on your pc, you may be able to collect, manipulate, upload, locate the facts saved for your computer. Why we use MySQL in this educational to create a database. Because MySQL software is Open Source. And MySQL is the maximum famous Open Source SQL database control gadget, is developed, allotted, and supported by means of Oracle Corporation. Also, The MySQL Database Server is very speedy, reliable, scalable, and smooth to use. MySQL Server works in customer/server or embedded systems. And many extra motives why we use MySQL to create a database. Now, permit we begin our guide.
Database Programming.
These commands below are meant for creating a MySQL database on a Windows working gadget computer.
Remember, every command must quit with a semicolon ( ;)
1. XAMPP
Download and set up Xampp server to your computer.
Now, open Xampp manipulate panel.
Then start MySQL.
XAMPP manipulate panel
Now, run Shell
2. Log In to the MySQL server.
For the primary, we have to log in to the MySQL server,
To do this, we have to enter a assertion to the command line with the following command.
mysql -uroot
In this situation, we've unique the consumer is root with u flag.
If you've got detailed a password at your MySQL server, you ought to upload p flag on the end of command line, instance.
mysql -uroot -p****
which **** man or woman assign your password.
At the other case you need to connect MySQL server to another host, you have to upload h flag on the stop of command line.
If you efficiently log in to MySQL server, You must see MySQL set off that looks very just like this:
mysql>
3. Create Database.
To create a database with the call SQL prompt ought to return with this result. kind the subsequent command:
create database SQL prompt ought to return with this result.;
If your database is successfully created, you may see the following message at MySQL prompt.
Query OK, 1 row affected (0.00 sec)
If a database of the same name already exists, then a new database will not be created and also you’ll obtain this mistake:
ERROR 1007 (HY000): Can't create database ' SQL prompt ought to return with this result. '; database exists
4. Show Databases.
To view the database you’ve efficiently created absolutely trouble the subsequent command:
show databases;
The result will much like this.
show databases result
5. Use Data Base.
The use command is used when you have a couple of database on a MySQL server and want to replace among them. Statement : use [DatabaseName]; as an instance;
use SQL prompt ought to return with this result.;
The result will much like this.
Database modified.
6. Create Table.
At this sections will show you the way to create a table interior ;database.
Now we will create a clients desk. The desk includes statistics showed at the photograph beneath.
table content material - create MySQL table
Type the following command at MySQL spark off;
create desk SQL prompt ought to return with this result.(The statements ought to appear like this; int(eleven), customerName varchar(50), phone varchar(50), addressLine1 varchar(50), metropolis varchar(50), state varchar(50), postalCode varchar(15), united states of america varchar(50));
If the desk efficaciously created, the SQL prompt have to return with this end result.
Query OK, zero rows affected (0.28 sec)
Do the same steps to create any other (customerNumber, customerName, cellphone, addressLine1, metropolis, state, postalCode, united states of america) values (1, 'Andy', '+62438999', 'royal road', 'kudus', 'important java', '59388', 'Indonesia');
7. Desc Table.
DESC is short for DESCRIBE, this function indicates the table structure.
the assertion should see like this; ; desc table call;
Example ;
desc clients;
SQL activate should go back with this end result Key 11 NULL phone addressLine1 metropolis NULL nation united states of america zero.03 sec)
Query OK, 0 rows affected (zero.63 sec)
Alter desk used for trade the desk shape, there are many alternatives to apply alter command.
Query OK, 0 rows affected (zero.63 sec)
the clients
desk.
Now upload a primary key at
PRI
subject.
type the subsequent command at MySQL Prompt;
alter table ;add number one key (
The statements ought to appear like this;
Query OK, 0 rows affected (zero.63 sec)
SQL spark off have to return with this end result.
Query OK, 0 rows affected (zero.63 sec)
Records: zero Duplicates: zero Warnings: 0
Now, lower back to the desc desk command.SQL activate must return with this end result. (customerNumber, customerName, cellphone, addressLine1, metropolis, state, postalCode, united states of america) values (1, 'Andy', '+62438999', 'royal road', 'kudus', 'important java', '59388', 'Indonesia');
You ought to see a PRI underneath the key column.
data kind: Varchar = records should be enclosed in citation marks.
This sections will give an explanation for to you the way to enter statistics to the table.The statements ought to appear like this; );
SQL activate should go back with this end result Key 11 NULL phone addressLine1 metropolis NULL nation united states of america zero.03 sec)
SQL activate should go back with this end result Key 11 NULL phone addressLine1 metropolis NULL nation united states of america zero.03 sec)
(customerNumber, customerName, cellphone, addressLine1, metropolis, state, postalCode, united states of america) values (1, 'Andy', '+62438999', 'royal road', 'kudus', 'important java', '59388', 'Indonesia');
SQL set off have to return with this end result.PRI Remember, to go into information must correspond to the records type, for instance.
data kind: Varchar = records should be enclosed in citation marks.
This sections will explain to you how to input data to the (customerNumber, customerName, cellphone, addressLine1, metropolis, state, postalCode, united states of america) values (1, 'Andy', '+62438999', 'royal road', 'kudus', 'important java', '59388', 'Indonesia');
data kind : date = type with the subsequent format (yyyy-mm-dd)
the assertion is ;How to reveal facts which is inserted into the table.
;
the assertion is ; ; (The statements ought to appear like this;, customerName, phone, addressLine1, city, state, postalCode, country) values (1, 'Andy', '+62438999', 'royal street', 'kudus', 'central java', '59388', 'Indonesia');
SQL activate should go back with this end result Key 11 NULL phone addressLine1 metropolis NULL nation united states of america zero.03 sec)
SQL prompt ought to return with this result.
Remember, to enter data must correspond to the data type, for ;
SQL spark off must return with this result.
show desk statistics - MySQL table
How to reveal exact desk data
the assertion is ;
How to show data which is inserted into the (customerNumber, customerName, cellphone, addressLine1, metropolis, state, postalCode, united states of america) values (1, 'Andy', '+62438999', 'royal road', 'kudus', 'important java', '59388', 'Indonesia');
;table ;
SQL prompt ought to return with this result.
;SQL prompt ought to return with this result. ;
SQL activate should go back with this end result Key 11 NULL phone addressLine1 metropolis NULL nation united states of america zero.03 sec)
;
SQL prompt ought to return with this result. ;
SQL activate should go back with this end result Key 11 NULL phone addressLine1 metropolis NULL nation united states of america zero.03 sec)
0 comments:
Post a Comment