Assignment 1
Assignment 1
Assignment 1
Theory:
MySQL is a Relational Management Database System(RDBMS), and ships with no GUI tools to
administer MySQL databases or manage data contained within the databases. Users may use the included
Command line tools, or use MySQL "front-ends", desktop software and web applications that create and
manage MySQL databases, build database structures, back up data, inspect status, and work with data
records. The official set of MySQL front-end tools, MySQL workbench is actively developed by Oracle,
and is freely available for use.
Client server system has one or more client process and one or more server processes,and a client process
can send a query to any one server process.Clients are responsible for user-interface issues,and servers
manages data and execute transaction .Thus, aclient process could run on a personal computer and send
queries to a server to a server running on a mainframe.
Components of SQL:
-This SQL syntax is used to create, modify and delete database structures.DDL syntax cannot be
applied to the manipulation of business data.DDL is almost always used by the database administrator, a
database schema implementer or an application developer. Every DDL command implicitly issues a
COMMIT making permanent all changes in the database.
Examples:
● CREATE: Create objects in database schema.
● ALTER: Alters the structure of objects that exist within the database schema.
● DROP: Drops objects that exist within database schema.
● TRUNCATE: Removes all records from a table, including all space allocated for the records.
● COMMENT:Adds comments ,generally used for proper documentation of a database schema.
Examples:
COMMIT,SAVEPOINT,ROLLBACK,SET TRANSACTION
● The commands used in MySQL are:
1) CREATE :
The CREATE command is used to create a database or create a table in a particular database.
Example: create table Student(Roll_no tinyint PRIMARY KEY,Fname varchar(20) NOT NULL,Lname
varchar(20),Mob_no char(10));
2)ALTER:MySQLALTER command is used to change a name of your table, any table field or if you
want to add or delete an existing column in a table.
Syntax:
Syntax: mysql> ALTER TABLE table_name DROP i; //i is the row you want to delete.
iii)CHANGE- Used to change a column's definition, use MODIFY or CHANGE clause along with
ALTER command. After the CHANGE keyword, you name the column you want to change, then specify
the new definition, which includes the new name
Syntax:
3)DELETE:used to delete a record from any MySQL table, then you can use SQL command DELETE
FROM.
INDEX: Indexing is the way of keeping table column data sorted so that searching and locating data
consumes less time. Hence indexes essentially improve the speed at which records can be located and
retrieved from a table.
Types of Index: SIMPLE INDEX: An index created on single column data is called Simple index.
COMPOSITE INDEX: An index created on multiple column data is called a composite index.
1)CREATE INDEX: A database index is a data structure that improves the speed of operations in a
table. Indexes can be created using one or more columns, providing the basis for both rapid random
lookups and efficient ordering of access to records.
Syntax:
Syntax:
VIEWS: A view is a table whoes rows are not explicitly stored in the database but are computed as
needed from a view defination.To reduce redundant data to the minimum possible, MySQL allows
creation of an object called a view .A view is mapped to a SELECT statement. This technique offers a
simple, effective way of hiding columns of a table.
Example: CREATE
VIEW stud_info(name,sid,course)
AS SELECT S.name,S.sid,S.cid
Syntax:
Example:
AS SELECT S.name,S.sid,S.cid
Syntax:
Example:
To connecting client and server in a network we have to follows the following steps :
Server side Commands:
1] > sudo -i
2] $ nano /etc/mysql/my.cnf
In this step we have to search #bind_address command and after finding this command comment
that command then used following options
ctrl v : It is used to move next page.
ctrl o : It is used to save the changes.
ctrl x : It is used to exit from file
5] mySql> grant all privileges on *.* to root@<client_IP> identified by "mysql" with grant
option;
This commands is used to login into mysql database then enter the correct password.
This command used for client for cereating the llogin and password.
Example:
where,
% is used for any computer which are in network can access server data.
and if not then insted of % we can also pass the IP address for particular client.
3] mySql> grant all on *.* to TEComp@'%' ;
Exit
Conclusion: