Wednesday, 25 April 2018

learning mysql database

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.7.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> create database student_db;
Query OK, 1 row affected (0.55 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| student_db         |
| sys                |
| wpress             |
+--------------------+
6 rows in set (0.31 sec)

mysql> use student_db;
Database changed
mysql> show tables;
Empty set (0.38 sec)

mysql> create table students
    -> (
    -> student_id char(5) primary key,
    -> first_name varchar(25) not null,
    -> last_name varchar(25) not null,
    -> gender varchar(6) not null,
    -> mobile_no char(11),
    -> email_id varchar(50)
    -> );
Query OK, 0 rows affected (0.62 sec)

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

mysql> describe students;
+------------+-------------+------+-----+---------+-------+
| Field      | Type        | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| student_id | char(5)     | NO   | PRI | NULL    |       |
| first_name | varchar(25) | NO   |     | NULL    |       |
| last_name  | varchar(25) | NO   |     | NULL    |       |
| gender     | varchar(6)  | NO   |     | NULL    |       |
| mobile_no  | char(11)    | YES  |     | NULL    |       |
| email_id   | varchar(50) | YES  |     | NULL    |       |
+------------+-------------+------+-----+---------+-------+
6 rows in set (0.18 sec)

mysql>

No comments:

Post a Comment

10 WAYS TO EARN IN DOLLARS

 Remote Work or Freelancing: With the rise of remote work opportunities, you can find freelance work in various fields such as writing, grap...