Perl scripting
Applications
OO Perl
Perl & Databases
© The scientific sentence. 2010
|
Perl Some basic MySQL orders
1. Connection to MySQL
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.4-beta-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> connect
Connection id: 6
Current database: *** NONE ***
2. mysql> show databases;
+-----------------------+
| Database |
+-----------------------+
| information_schema |
| academia |
| aromatics |
| atoms |
| books |
| boxes |
| cake |
| compounds |
| joomlas |
| molecules |
| molecules_development |
| molecules_production |
| molecules_test |
| moodle |
| mysql |
| organics_development |
| organics_production |
| organics_test |
| sulfur_compounds |
| test |
+-----------------------+
20 rows in set (0.45 sec)
3. mysql> connect academia;
Connection id: 15
Current database: academia
4. mysql> show tables;
+--------------------+
| Tables_in_academia |
+--------------------+
| disciplines |
| friends |
| molecules |
| physicists |
| professors |
| programs |
+--------------------+
6 rows in set (0.00 sec)
5. mysql> select * from physicists;
+---------+------------+-------------+------------+------------+-------------------+
| phys_id | first_name | last_name | birth_date | death_date | discipline |
+---------+------------+-------------+------------+------------+-------------------+
| 101 | Joseph | Thomson | 1856 | 1940 | atomic |
| 102 | Ernest | Rutherford | 1871 | 1937 | nuclear |
| 103 | Max | Planck | 1858 | 1947 | radiation |
| 105 | Niels | Bohr | 1885 | 1962 | atomic |
| 106 | Louis | DeBroglie | 1892 | 1987 | wave_mechanics |
| 107 | Erwin | Schrodinger | 1887 | 1961 | quantum_mechanics |
| 108 | Maurice | Dirac | 1902 | 1984 | atomic |
| 109 | Ludwig | Boltzmann | 1844 | 1906 | stat_physics |
+---------+------------+-------------+------------+------------+-------------------+
8 rows in set (0.00 sec)
mysql>
6. Adding "Faraday" with Perl gives: ;
mysql> select * from physicists;
+---------+------------+-------------+------------+------------+-------------------+
| phys_id | first_name | last_name | birth_date | death_date | discipline |
+---------+------------+-------------+------------+------------+-------------------+
| 101 | Joseph | Thomson | 1856 | 1940 | atomic |
| 102 | Ernest | Rutherford | 1871 | 1937 | nuclear |
| 103 | Max | Planck | 1858 | 1947 | radiation |
| 105 | Niels | Bohr | 1885 | 1962 | atomic |
| 106 | Louis | DeBroglie | 1892 | 1987 | wave_mechanics |
| 107 | Erwin | Schrodinger | 1887 | 1961 | quantum_mechanics |
| 108 | Maurice | Dirac | 1902 | 1984 | atomic |
| 109 | Ludwig | Boltzmann | 1844 | 1906 | stat_physics |
| 112 | Michael | Faraday | 1791 | 1867 | Elecromagetism |
+---------+------------+-------------+------------+------------+-------------------+
9 rows in set (0.02 sec)
mysql>
|
|
|
|