DB online command

  1. to connect to MySqL :
#! /bin/tcsh -f
 mysql -h dbx.star.bnl.gov --port=3316 -u "" -p"" StarDb

      2. to see the whole db :


show databases;

which gives :
+----------------------+
| Database             |
+----------------------+
| information_schema   |
| Calibrations         |
| Calibrations_eemc    |
| Calibrations_emc     |
| Calibrations_fms     |
| Calibrations_ftpc    |
| Calibrations_l2      |
| Calibrations_l3      |
| Calibrations_pmd     |
| Calibrations_pp2pp   |
| Calibrations_rhic    |
| Calibrations_rich    |
| Calibrations_ssd     |
| Calibrations_svt     |
| Calibrations_tof     |
| Calibrations_tpc     |
| Calibrations_tracker |
| Calibrations_trg     |
| Calibrations_zdc     |
| Conditions           |
| Conditions_trg       |
| Geometry             |
| Geometry_eemc        |
| Geometry_emc         |
| Geometry_fms         |
| Geometry_ftpc        |
| Geometry_pmd         |
| Geometry_pp2pp       |
| Geometry_ssd         |
| Geometry_svt         |
| Geometry_tof         |
| Geometry_tpc         |
| RunLog               |
| RunLog_l3            |
| RunLog_onl           |
| RunLog_rhic          |
| StarDb               |
| test                 |
+----------------------+
38 rows in set (0.00 sec)
 

     3. To select a specific table  :


use Calibrations_ssd;

then


show tables;

which gives :
+----------------------------+
| Tables_in_Calibrations_ssd |
+----------------------------+
| GainIDs                    |
| NodeRelation               |
| Nodes                      |
| StripIDs                   |
| schema                     |
| ssdGainCalibWafer          |
| ssdNoise                   |
| ssdStripCalib              |
| ssdWaferConfiguration      |
| structure                  |
+----------------------------+
10 rows in set (0.00 sec)
 

    4. to see the details of a given table

explain ssdStripCalib;

 which gives :
+-----------+---------------------+------+-----+---------------------+----------------+
| Field     | Type                | Null | Key | Default             | Extra          |
+-----------+---------------------+------+-----+---------------------+----------------+
| dataID    | int(11)             | NO   | MUL | NULL                | auto_increment |
| entryTime | timestamp           | NO   | MUL | CURRENT_TIMESTAMP   |                |
| nodeID    | int(11)             | NO   | PRI | 0                   |                |
| elementID | mediumint(9)        | NO   | PRI | 0                   |                |
| beginTime | datetime            | NO   | PRI | 1970-01-01 00:00:00 |                |
| endTime   | datetime            | NO   |     | 2037-01-01 00:00:00 |                |
| flavor    | char(32)            | NO   | PRI | ofl                 |                |
| schemaID  | int(11)             | NO   |     | 1                   |                |
| deactive  | int(10) unsigned    | NO   | PRI | 0                   |                |
| id        | int(11)             | YES  |     | NULL                |                |
| pedestals | tinyint(3) unsigned | YES  |     | NULL                |                |
| rms       | tinyint(3) unsigned | YES  |     | NULL                |                |
+-----------+---------------------+------+-----+---------------------+----------------+
12 rows in set (0.00 sec)

 

    5. to have the value of a given entry with some conditon :

mysql> select entryTime,beginTime,flavor,id,pedestals,rms from ssdStripCalib where id=907912;


    6. condition based on entryTime/beginTime

 

 

 

 

 

select id from pxlLadderOnSector where entryTime>"2013-04-15 00:00:00";