Differences
This shows you the differences between two versions of the page.
linux_wiki:create_a_simple_database_schema [2018/04/20 16:32] billdozor [Create a Database] |
linux_wiki:create_a_simple_database_schema [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Create A Simple Database Schema ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | Creating a simple database in MariaDB. | ||
- | |||
- | ---- | ||
- | |||
- | ====== Lab Setup ====== | ||
- | |||
- | The following virtual machines will be used: | ||
- | * server2.example.com (192.168.1.151) -> Database here | ||
- | |||
- | **Previous Section Completed** | ||
- | * [[linux_wiki: | ||
- | |||
- | ---- | ||
- | |||
- | ====== Basic Database Commands ====== | ||
- | |||
- | Connect to the database | ||
- | <code bash> | ||
- | mysql -u root -p | ||
- | </ | ||
- | |||
- | \\ | ||
- | Show databases available | ||
- | <code bash> | ||
- | MariaDB [(none)]> | ||
- | </ | ||
- | |||
- | \\ | ||
- | Open a database | ||
- | <code bash> | ||
- | MariaDB [(none)]> | ||
- | </ | ||
- | |||
- | \\ | ||
- | Display tables in the database | ||
- | <code bash> | ||
- | MariaDB [(mysql)]> | ||
- | </ | ||
- | |||
- | \\ | ||
- | Display all (SELECT *) contents of the table ' | ||
- | <code bash> | ||
- | MariaDB [(mysql)]> | ||
- | </ | ||
- | |||
- | \\ | ||
- | Show details of the table ' | ||
- | <code bash> | ||
- | MariaDB [(mysql)]> | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ====== Create a Database ====== | ||
- | |||
- | \\ | ||
- | Create a database called ' | ||
- | <code bash> | ||
- | MariaDB [(none)]> | ||
- | </ | ||
- | |||
- | \\ | ||
- | Open the new database | ||
- | <code bash> | ||
- | MariaDB [(none)]> | ||
- | </ | ||
- | |||
- | \\ | ||
- | Create a new table in the emails database | ||
- | <code bash> | ||
- | MariaDB [emails]> | ||
- | </ | ||
- | * When you create a table, you must define the names of the columns and the type of data they should contain | ||
- | * userID INT -> Named userID and of type integer | ||
- | * userFirstName char(25) -> Named userFirstName and of type characters up to 25 long | ||
- | |||
- | \\ | ||
- | Show the tables in the emails DB, display contents of the users table, show the data types in the users table. | ||
- | <code bash> | ||
- | MariaDB [emails]> | ||
- | MariaDB [emails]> | ||
- | MariaDB [emails]> | ||
- | </ | ||
- | |||
- | ---- | ||