MySQL is an open source RDBMS by ORACLE
RDBMS - Relational Database Management System.
I have shared some useful things to learn MySQL as a beginner.
Practise MySQL in Command line tool gives more confidence of learning than using any other IDE.(in my point of view).
Before proceeding keep it in mind that,all queries/commands should be terminated using a delimiter only, the default delimiter for MySQL is ; ( semicolon). The delimiter can also be changed. I am here using default delimiter.
Create database:
To create a new database
Create Database [database name]
Eg: Create database saba;
o/p: Query OK, 1 row affected (0.11 sec)
Show the existing databases:-
This command list out all existing databases that the user can have rights to access.
Show databases;
Eg: show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| saba |
| test |
| test6 |
+--------------------+
4 rows in set (0.22 sec)
Use database:
If a user need to perform any action in an database user should select the database first,for selecting the database USE command is used. User can select only one database using USE command. Without selecting database user can't perform any operations in that database.
use [Databasename]
Eg: use saba;
Create tables:-
To create tables in a database use
create table [tablename(field1 datatype,field2 datatype)];
Eg: create table table1(id int(2),name varchar(25),address varchar(50));
Query OK, 0 rows affected (0.28 sec)
Describe the structure of an table
describe tablename
eg: describe saba;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| id | int(2) | YES | | NULL | |
| name | varchar(25) | YES | | NULL | |
| address | varchar(50) | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
Show Tables;
on executing this command it returns all tables in the database
eg: show tables;
+----------------+
| Tables_in_saba |
+----------------+
| table1 |
+----------------+
1 row in set (0.01 sec)
Insert data into table;
To insert the data into table use this
insert into <tablename>(columnname,columnname)values('values for the column',value for the column);
if the value of the column is string or character it should be enclosed within single quotes (eg 'saba ').
eg:
insert into table1(id,name,address) values(1,'saba','chennai');
Query OK, 1 row affected (0.00 sec)
RDBMS - Relational Database Management System.
I have shared some useful things to learn MySQL as a beginner.
Practise MySQL in Command line tool gives more confidence of learning than using any other IDE.(in my point of view).
Before proceeding keep it in mind that,all queries/commands should be terminated using a delimiter only, the default delimiter for MySQL is ; ( semicolon). The delimiter can also be changed. I am here using default delimiter.
Create database:
To create a new database
Create Database [database name]
Eg: Create database saba;
o/p: Query OK, 1 row affected (0.11 sec)
Show the existing databases:-
This command list out all existing databases that the user can have rights to access.
Show databases;
Eg: show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| saba |
| test |
| test6 |
+--------------------+
4 rows in set (0.22 sec)
Use database:
If a user need to perform any action in an database user should select the database first,for selecting the database USE command is used. User can select only one database using USE command. Without selecting database user can't perform any operations in that database.
use [Databasename]
Eg: use saba;
Create tables:-
To create tables in a database use
create table [tablename(field1 datatype,field2 datatype)];
Eg: create table table1(id int(2),name varchar(25),address varchar(50));
Query OK, 0 rows affected (0.28 sec)
Describe the structure of an table
describe tablename
eg: describe saba;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| id | int(2) | YES | | NULL | |
| name | varchar(25) | YES | | NULL | |
| address | varchar(50) | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
Show Tables;
on executing this command it returns all tables in the database
eg: show tables;
+----------------+
| Tables_in_saba |
+----------------+
| table1 |
+----------------+
1 row in set (0.01 sec)
Insert data into table;
To insert the data into table use this
insert into <tablename>(columnname,columnname)values('values for the column',value for the column);
if the value of the column is string or character it should be enclosed within single quotes (eg 'saba ').
eg:
insert into table1(id,name,address) values(1,'saba','chennai');
Query OK, 1 row affected (0.00 sec)
No comments:
Post a Comment