Top Banner
MY SQL INTRODUCTION TO LOGIN BASIC COMMANDS OTHER COMMANDS
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Mysql Ppt

MY SQL

INTRODUCTION TO LOGIN BASIC COMMANDS OTHER COMMANDS

Page 2: Mysql Ppt

INTRODUCTION

MySQL is a key part of LAMP (Linux, Apache, MySQL, PHP / Perl / Python), the fast-growing open source enterprise software stack. More and more companies are using LAMP as an alternative to expensive proprietary software stacks because of its lower cost and freedom from platform lock-in.

MySQL was originally founded and developed in Sweden by two Swedes and a Finn: David Axmark, Allan Larsson and Michael "Monty" Widenius, who had worked together since the 1980's.

Page 3: Mysql Ppt

TO LOGIN

To login (from unix shell) use -h only if needed.the command used to login is

[mysql dir]/bin/mysql -h hostname -u root -p

Page 4: Mysql Ppt

DDL COMMANDS

DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database.

Examples:

CREATE, ALTER, DROP statements

Page 5: Mysql Ppt

CREATE

Creates objects in the database the queery used to create theobject is

create database [databasename];

Example :

create database [employee];

Page 6: Mysql Ppt

ALTER

Alters objects of the database

ALTER TABLE <table_name>ADD <column_name1> <datatype1> <constraint1> ALTER TABLE <table_name>ALTER COLUMN <column_name1> <datatype1>

<constraint1> ALTER TABLE <table_name>DROP COLUMN <column_name1> <datatype1>

Page 7: Mysql Ppt

DROPDeletes objects of the database

the syntax for dorp is

DROP TABLE [ IF EXISTS ] table_name1, table_name2, ....

Removes the table(s) from the database. The IF EXISTS clause will drop the table only if it exists. If this clause is not present an error is generated if the table does not exist. Any data that was in a dropped table is lost so use with care.

Page 8: Mysql Ppt

DML COMMANDS

DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database.

Examples:

SELECT, UPDATE, INSERT statements

Page 9: Mysql Ppt

SELECT

SELECT [ DISTINCT | ALL ] column_expression1, column_expression2, .... [ FROM from_clause ] [ WHERE where_expression ] [ GROUP BY expression1, expression2, .... ] [ HAVING having_expression ] [ ORDER BY order_column_expr1,

order_column_expr2, .... ]

The SELECT statement is used to form queries for extracting information out of the database. The following example query will return the number, quantity and price of all orders for more than 5 items sorted in descending order by order number. to the output.

Page 10: Mysql Ppt

UPDATE

UPDATE table_name SET col_name1 = expression1, col_name2 = expres

sion2, .... [ WHERE expression ] [ LIMIT limit_amount ]

Updates information in a table. The SET clause is a list of assignments that describe how the columns of the data matched by the WHERE clause are to be updated.

Page 11: Mysql Ppt

INSERT

INSERT INTO table_name [ ( col_name1, col_name2, .... ) ]

VALUES ( expression1_1, expression1_2, .... ), ( expression2_1, expression2_2, .... ), ....

This is the SQL command to insert records into a table in the database. This statement comes in three forms.

Page 12: Mysql Ppt

The Second form of insert command

INSERT INTO table_name [ ( col_name1, col_name2, .... ) ]

SELECT ...

The Third form of insert cmmand

INSERT INTO table_name SET col_name1 = expression1, col_name2 =

expression2, ....

Page 13: Mysql Ppt

TCL COMMSNDS

TCL is abbreviation of Transactional Control Language. It is used to manage different transactions occurring within a database.

Examples:

COMMIT, ROLLBACK statements

Page 14: Mysql Ppt

COMMIT AND ROLLBACK

Saves work done in transactions

The SyntaxCOMMIT

ROLLBACK

Transactional operations for closing a transaction and either committing all the changes made or rolling back and disposing all changes

Page 15: Mysql Ppt

DCL COMMANDS

DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.

Examples:

GRANT, REVOKE statements

Page 16: Mysql Ppt

GRANT AND REVOKE

GRANT privileges ON database_object TO ( PUBLIC | user_list )[ WITH GRANT OPTION ]

REVOKE [ GRANT OPTION FOR ] privi- leges ON database_objectFROM ( PUBLIC | user_list )

Grants or revokes types of access on a table or view to a user. When a table or view is created the system gives full grant options to the user that created the object.

Page 17: Mysql Ppt

OTHER COMMANDS SET

SET variable = expressionSET AUTO COMMIT ( ON | OFF )SET TRANSACTION ISOLATION LEVEL ( SERIALIZABLE )SET SCHEMA schema_name

Makes a change to the state of the connection. SET AUTO COMMIT is used to switch transaction 'auto commit mode' on or off.

Page 18: Mysql Ppt

DESCRIBE

SYNTAX

DESCRIBE table_name

This command provides information about the columns of the table. It shows the column names, the type / size and scale (if applicable) and other useful information.

Page 19: Mysql Ppt

SHOW

SHOW engine_variable

engine_variable ::= TABLES | SCHEMA | STATUS | CONNECTIONS

Shows internal information about the database system. SHOW TABLES returns a list of tables in the database. SHOW STATUS returns debugging and statistical information about the internal state of the database engine. SHOW CONNECTIONS returns a snapshot of the current connections on the database. SHOW SCHEMA lists all the schema defined.

Page 20: Mysql Ppt

SHUTDOWN

SYNTAX

SHUTDOWN

Shuts down the database. If the database is running as a server the database shuts down cleanly and the process is stopped. If the database is embedded in a Java application it is cleanly put into a shut down state.

Page 21: Mysql Ppt

THANK YOU