MY SQL MySQL is a relational database management system.The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. MySQL is owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Sun Microsystems, a subsidiary of Oracle Corporation
Features <ul><li>A broad subset of ANSI SQL 99, as well as extensions </li></ul><ul><li>Cross-platform support </li></ul><ul><li>Stored procedures </li></ul><ul><li>Triggers </li></ul><ul><li>Cursors </li></ul><ul><li>Updatable Views </li></ul><ul><li>True Varchar support </li></ul><ul><li>SSL support </li></ul><ul><li>Query caching </li></ul><ul><li>Sub-SELECTs (i.e. nested SELECTs) </li></ul><ul><li>Full-text indexing and searching using MyISAM engine </li></ul><ul><li>Embedded database library </li></ul><ul><li>Hot backup (via mysqlhotcopy) under certain conditions </li></ul>
Management and Graphical Frontends MySQL is primarily an RDBMS and therefore ships with no GUI tools to administer MySQL databases or manage data contained within. Users may use the included command-line tools, or download MySQL frontends from various parties that have developed desktop software and web applications to manage MySQL databases, build database structure, and work with data reco
MySQL can be built and installed manually from source code, but this can be tedious so it is more commonly installed from a binary package unless special customizations are required. On most Linux distributions the package management system can download and install MySQL with minimal effort, though further configuration is often required to adjust security and optimization settings. It is still most commonly used in small to medium scale single-server deployments, either as a component in a LAMP based web application or as a standalone database server. Much of MySQL's appeal originates in its relative simplicity and ease of use, which is enabled by an ecosystem of open source tools such as phpMyAdmin. USAGE:
MYSQL IN SYSTEM: Inorder to use the mysql we again need the web server package called 'XAMPP ' “ Xampp is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages.” XAMPP requires only one zip, tar or exe file to be downloaded and run, and little or no configuration of the various components that make up the web server is required. XAMPP is regularly updated to incorporate the latest releases of Apache/MySQL/PHP and Perl.
INSTALLATION PROCEDURE Step 1: We need to have the xampp for linux inorder the run applications so(as per step 1) ,download the xampp for linux with any favourable version on to the computer
Step 2: After the successful downloading,we need to extract the 'tar' file on to the system,select a path and just extract them using the following commands gunzip -d httpd-2_0_NN.tar.gz tar xvf httpd-2_0_NN.tar *NN -refers to the current xampp versions
Inorder to configure the ,we need to locate the xampp folder to which it is extracted. After the location of these file we can find the configure file in the 'etc' folder as “my.cnf”, inside which we can find the configuration file “ configuration file main Apache HTTP server configuration . It contains the configuration directives that give the server its instructions”
In this file, you can use all long options that a program supports. If you want to know which options a program supports, run the program with the "--help" option. Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /opt/lampp/var/mysql/mysql.sock skip-locking key_buffer = 16M max_allowed_packet = 1M table_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M
To know where all the plugins will be ,then; plugin_dir = /opt/lampp/lib/mysql/plugin/ ------------------------------------------------------------------ We should never prefer tcp/Ip ports,because it will creating a security enhancement,so if all the ports are after a same host then wen need to use the “named pipes” , in windows enabling this will make mysql useless
Replication Master Server (default) binary logging is required for replication log-bin deactivated by default since XAMP 1.4.11 log-bin=mysql-bin required unique id between 1 and 2^32 - 1defaults to 1 if master-host is not set but will not function as a master if omitted server-id = 1 Replication of master
IMPORTING SQL: Any relational database can be imported into the xampp tool for furthur,this can be done using the “import” and we need to browse the ' .sql' which is to be imported,after selecting it then click on the “go” button and the sql will be imported
EXPORTING SQL: At fist we need to open the xampp for the database query,then after creating the table and inserting the values into the database,[which can be done either in the simplified or ordinary method like writing the sql query by ourself],then clicking the “EXPORT” we can save the sql in its format and which can be used in furthur endaveour.
CREATE : To create an empty database named "employees" on your DBMS. SYNTAX: CREATE TABLE personal_info (first_name char(20) not null, last_name char(20) not null, employee_id int not null) n our example, the table contains three attributes: first_name, last_name and employee_id DDL COMMANDS:
USE COMMAND: The USE command allows you to specify the database you wish to work with within your DBMS. For example, if we're currently working in the sales database and want to issue some commands that will affect the employees database, we would preface them with the following SQL command: USE employees It's important to always be conscious of the database you are working in before issuing SQL commands that manipulate data.
ALTER : Once you've created a table within a database, you may wish to modify the definition of it. The ALTER command allows you to make changes to the structure of a table without deleting and recreating it. Take a look at the following command: ALTER TABLE personal_info ADD salary money null This example adds a new attribute to the personal_info table -- an employee's salary. The "money" argument specifies that an employee's salary will be stored using a dollars and cents format. Finally, the "null" keyword tells the database that it's OK for this field to contain no value for any given employee.
DROP : The final command of the Data Definition Language, DROP, allows us to remove entire database objects from our DBMS. For example, if we want to permanently remove the personal_info table that we created, we'd use the following command: DROP TABLE personal_info
INSERT : The INSERT command in SQL is used to add records to an existing table. Returning to the personal_info example from the previous section, let's imagine that our HR department needs to add a new employee to their database. They could use a command similar to the one shown below: INSERT INTO personal_info values('bart','simpson',12345,$45000)
SELECT : The SELECT command is the most commonly used command in SQL. It allows database users to retrieve the specific information they desire from an operational database. Let's take a look at a few examples, again using the personal_info table from our employees database SELECT * from personal_info
UPDATE : The UPDATE command can be used to modify information contained within a table, either in bulk or individually. UPDATE personal_info SET salary = salary * 1.03
DELETE : The DELETE command with a WHERE clause can be used to remove his record from the personal_info table: DELETE FROM personal_info WHERE employee_id = 12345
DML COMMANDS: Group By: The Group By statement in SQL is used for aggregation, which means that the result that is returned is based on grouping of results based on a column aggregation. SELECT Roll_No, SUM(Marks) FROM t_students WHERE Class = 5 GROUP BY Roll_No
Order By: The Order By clause in SQL is used to set the sequence of the output in terms of being alphabetical, magnitude of size, order of date. It may accompanied by an 'asc' or 'desc' clause so as to specify whether the results are in ascending or descending order. Note: The results of a select query that does not use asc or desc is in ascending order, by default. SELECT fname, lname FROM t_students ORDER BY fname ASC;
BETWEEN: The BETWEEN keyword allows for selecting a range. The syntax for the BETWEEN clause is as follows: SELECT "column_name" FROM "table_name" WHERE "column_name" BETWEEN 'value1' AND 'value2' This will select all rows whose column has a value between 'value1' and 'value2'. UNIQUE: The UNIQUE constraint ensures that all values in a column are distinct. For example, in the following CREATE TABLE statement, CREATE TABLE Customer (SID integer Unique, Last_Name varchar (30), First_Name varchar(30)); Column "SID" has a unique constraint, and hence cannot include duplicate values. Such constraint does not hold for columns "Last_Name" and "First_Name"
S QL has several arithematic functions, and they are: • AVG: Average of the column. • COUNT: Number of records. • MAX: Maximum of the column. • MIN: Minimum of the column. • SUM: Sum of the column. The syntax for using functions is, SELECT "function type" ("column_name") FROM "table_name" SQL FUNCTIONS: