MySQL
INTRODUCTION
today we are living in the 20th century and every day tons of data are generated. for storing these tons of data new and advanced computers are introduced like cloud computing etc. these generations of data are genuine because every day in banks new transactions are processed, there are a huge variety of online stores which keeps tracking of there users for example name, address email etc, the schools and colleges keep all confidential information of the student from the beginning till now and there are many organisation which are generating huge data.So, consider if someone(named boss) tells you to handle all this and present this in a well-defined manner then what will you do. (one question arises here, why someone wants to handle and present it in a well-defined data? The answer is that the boss wants to do some predictions that in the next three or four years where the position of the company, the company will be in the profit or in loss )so, today I will teach you to how to handle and sort these data one place without any problem.
Today I am going to talk about the best software which will come in use for handling data. the name of the software is MySQL.it is developed by Oracle Corporation, the stable release is 8.0.16 we are going to use version 8.0.in MySQL, there are many inbuilt packages which help to handle data like
how to install MySQL?
- Download the software from the MySQL website .link is given you can directly approach to it.https://dev.mysql.com/downloads/mysql/. download and install the software, I hope you can do it.scroll the page down, you will see this kind of interface.
- while installing it will take permission, which packages you want to install. I prescribe install all the applications.it takes some time because the applications are downloaded and executed.it's interface is like this.
how to run MySQL?
- go to start, and open MySQL command line prompt.its interface is like this.
- for creating Database type CREATE DATABASE XYZ; create database is a command for SQL which instruct SQL to build a database whose name is XYZ.remember to use a semicolon(;).
- for creating tables type CREATE TABLE COMPANY; create a table is the code given to construct a table whose name is a company.
- for deleting a database DROP DATABASE XYZ;
- for deleting a table DROP TABLE COMPANY;
- for listing all databases SHOW DATABASES;
- for listing all tables in a database SHOW TABLES XYZ; show tables is a command used to list all the tables of the database named XYZ.
- for selecting the particular database from the list of database type USE NAME_OF_DB;
- for seeing the database's field formats type DESCRIBE NAME_OF_DB; this command is used to describe the table's format that how many characters or an integer variable is used.
- Shows all data in table type SELECT * FROM TABLE_NAME;
- to build a table (example-1)
CREATE TABLE COMPANY(
employee_name VARCHAR(20),
employee_id INT PRIMARY KEY,
address int,
branch (20) VARCHAR) FOREIGN KEY;
CREATE TABLE whose name is COMPANY, in this, we have used four attributes employee_name,employee_id, address and branch of the employee.infront of every attribute datatype have been declared, in character type data in SQL we have to declare a total number of length while in integer type this is not important. for example in front of employee_name since it is a character so it is declared(VARCHAR means variable character whose values can differ in different situation.)that the employee name must contain only 20 letters,it will not accept that name whose length of name exceeds 20,for acceptance you have to increase the total number of length which will be declared in front of the attributes.
like this, you can create as many tables as per your requirement.
PRIMARY KEY => is the command which declares that the attribute will not take a duplicate entry, and we can easily point out or can easily pick the information of a particular individual by their employee_id.
FOREIGN KEY => is the command which declares that this attribute has some relation from another table(imagine you created a database for your company which has many tables like a table of total employee_information, table of branch, table of client etc and suppose there is an employee who has some relation in table of client and in table of employee information.so for solving this problem we use a command FOREIGN KEY . )
- to insert the values type
INSERT INTO COMPANY VALUES( VALUES OF THE ATTRIBUTES );
- insert (example-1)
INSERT INTO COMPANY VALUES ("Varun",1,"Ranchi","scraping");
remember to use semicolon at the end of the code. always write the values in proper alignment for example if we interchange the values from Ranchi to 1, it will not except. because while making the table we have declared that the third position is character and second position is an integer, so in character position, it will never except integer and vice versa.
- To delete a column ALTER TABLE [table_name]DROP COLUMN [column_name];
- To add a new column to db
[table_name] ADD COLUMMN [new_column_name] VARCHAR (20);
- To delete any element of a table
DELETE FROM table_name
WHERE condition = (as per your want);
- Change column name
ALTER TABLE [table_name] CHANGE NAME [old_column_name] [new_column _name]VARCHAR(40)
to see the all contents ,type SELECT * FROM TABLE_NAME;
to see more quries go to github link .https://github.com/rajroshansharma/MySQL_sample/blob/master/sample.txt
to see more quries go to github link .https://github.com/rajroshansharma/MySQL_sample/blob/master/sample.txt
So, this was the basis of MySQL in brief, which will help you to get started with MySQL .hope you liked this, please comment, like and share this to your friends.if you have any dought than please comment.i will make blogs on projects on MySQL.
This comment has been removed by the author.
ReplyDeleteGreat,maxstanding lover reply here
ReplyDelete