html

DATABASE CREATION IN MYSQL (KOUSZ)

Blogger Tricks


STEP BY STEP METHOD OF CREATING MYSQL DATABASE (KOUSZ)
1.command to enter to mysql:

247-DESK2 kovalan # mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.6.19-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

2.TYPE THE COMMAND  SHOW DATABASE TO VIEW THE DATABASE FILE

 mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| PENCIL             |
| WATCH              |
| books              |
| mysql              |
| performance_schema |
| test1              |
| uva                |
+--------------------+
8 rows in set (0.51 sec)

3. TO VIEW THE DATABASE FILE :
 mysql> use books
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> 

4. commad to view the tables:

 mysql> show tables;
+-----------------+
| Tables_in_books |
+-----------------+
| authors         |
+-----------------+
1 row in set (0.00 sec)
 

5.command to  add values in table:

mysql> create table linux (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    -> name VARCHAR(20),
    -> department VARCHAR(30),
    -> unit VARCHAR(32),
    -> signup_date DATE);
Query OK, 0 rows affected (1.87 sec)

mysql> show tables;
+-----------------+
| Tables_in_books |
+-----------------+
| authors         |
| linux           |
+-----------------+
2 rows in set (0.05 sec)

6.command to view the values in the table:
mysql> DESCRIBE linux;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| name        | varchar(20) | YES  |     | NULL    |                |
| department  | varchar(30) | YES  |     | NULL    |                |
| unit        | varchar(32) | YES  |     | NULL    |                |
| signup_date | date        | YES  |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+
5 rows in set (0.80 sec)



mysql> SELECT * FROM linux;
+----+-------+------------+------+-------------+
| id | name  | department | unit | signup_date |
+----+-------+------------+------+-------------+
|  1 | KOUSZ | IT         | I    | 2015-10-29  |
+----+-------+------------+------+-------------+
1 row in set (0.07 sec)
7.command to insert the value for the table Linux:


 mysql> INSERT INTO `linux` (`id`,`name`,`department`,`unit`,`signup_date` ) VALUES (NULL, "test","ECE","II", '2015-10-29');
Query OK, 1 row affected (0.92 sec)

8. command to view the data in the selected tables linux:


mysql> SELECT * FROM linux;
+----+-------+------------+------+-------------+
| id | name  | department | unit | signup_date |
+----+-------+------------+------+-------------+
|  1 | KOUSZ | IT         | I    | 2015-10-29  |
|  2 | test  | ECE        | II   | 2015-10-29  |
+----+-------+------------+------+-------------+
2 rows in set (0.04 sec)














No comments:

Post a Comment