20.27 MySQL Basics
Connect to the local database server as user nhds
:
Identify the current database:
mysql> select DATABASE();
+------------+
| DATABASE() |
+------------+
| |
+------------+
1 row in set (0.00 sec)
List all available databases with:
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| nhds |
| test |
+----------+
3 rows in set (0.00 sec)
Select a particular database:
List the available tables:
mysql> show tables;
+----------------+
| Tables_in_nhds |
+----------------+
| nhds96 |
| nhds97 |
| nhds98 |
| nhds99 |
+----------------+
4 rows in set (0.00 sec)
List details of the structure of a table:
mysql> describe nhds99;
+---------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------+------+-----+---------+-------+
| svy_year | int(11) | YES | | NULL | |
| newborn | char(1) | YES | | NULL | |
| age_unit | char(1) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
| race | char(1) | YES | | NULL | |
| m_status | char(1) | YES | | NULL | |
| dis_month | int(11) | YES | | NULL | |
| dis_status | char(1) | YES | | NULL | |
| days_care | int(11) | YES | | NULL | |
| los_flag | char(1) | YES | | NULL | |
| geo_region | char(1) | YES | | NULL | |
| no_beds | char(1) | YES | | NULL | |
| hos_ownership | char(1) | YES | | NULL | |
| ana_weight | int(11) | YES | | NULL | |
| dc1 | char(5) | YES | | NULL | |
| dc2 | char(5) | YES | | NULL | |
| dc3 | char(5) | YES | | NULL | |
| dc4 | char(5) | YES | | NULL | |
| dc5 | char(5) | YES | | NULL | |
| dc6 | char(5) | YES | | NULL | |
| dc7 | char(5) | YES | | NULL | |
| pc1 | char(4) | YES | | NULL | |
| pc2 | char(4) | YES | | NULL | |
| pc3 | char(4) | YES | | NULL | |
| pc4 | char(4) | YES | | NULL | |
| p_src_payment | char(2) | YES | | NULL | |
| s_src_payment | char(2) | YES | | NULL | |
| drg | char(3) | YES | | NULL | |
+---------------+---------+------+-----+---------+-------+
29 rows in set (0.00 sec)
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0