linux_wiki:perform_simple_sql_queries_against_a_database

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux_wiki:perform_simple_sql_queries_against_a_database [2018/04/20 12:30]
billdozor [Lab Setup]
linux_wiki:perform_simple_sql_queries_against_a_database [2019/05/25 23:50]
Line 1: Line 1:
-====== Perform Simple SQL Queries Against A Database ====== 
- 
-**General Information** 
- 
-Basic SQL commands. 
- 
----- 
- 
-====== Lab Setup ====== 
- 
-The following virtual machines will be used: 
-  * server1.example.com (192.168.1.150) -> Perform any client testing here 
-  * server2.example.com (192.168.1.151) -> Install the database here 
- 
-**Previous Section Completed** 
-  * [[linux_wiki:install_and_configure_mariadb|Install and Configure MariaDB]] 
- 
----- 
- 
-====== Basics of SQL: Connect and Navigate ====== 
- 
-Connect to the database 
-<code bash> 
-mysql -u root -p 
-</code> 
- 
-\\ 
-Show databases on the system 
-<code bash> 
-MariaDB [(none)]> SHOW DATABASES; 
-</code> 
- 
-\\ 
-Use a specific database called 'emails' 
-<code bash> 
-MariaDB [(none)]> USE emails; 
-</code> 
- 
-\\ 
-Show the tables in the database, emails 
-<code bash> 
-MariaDB [emails]> SHOW TABLES; 
-</code> 
- 
-\\ 
-Show the fields available in a table called 'users' 
-<code bash> 
-MariaDB [emails]> DESCRIBE users; 
-</code> 
- 
-====== Basics of SQL: Add,Remove,Modify ====== 
- 
-\\ 
-Insert a new row/entry into a table 
-<code bash> 
-MariaDB [emails]> INSERT INTO users (userID,userFirstName,userLastName,userEmailAddress) VALUES (001,"Robert","Jones","robertjones@example.com"); 
-</code> 
- 
-\\ 
-Show all entries from the users table 
-<code bash> 
-MariaDB [emails]> SELECT * FROM users; 
-</code> 
- 
-\\ 
-Show all entries from the users table where the last name equals "Smith" 
-<code bash> 
-MariaDB [emails]> SELECT * FROM users WHERE userLastName="Smith"; 
-</code> 
- 
-\\ 
-Delete the entry where the user id is 2 
-<code bash> 
-MariaDB [emails]> DELETE FROM users WHERE userID=2; 
-</code> 
- 
-\\ 
-Update the entry of Jane Smith to change her last name and email address 
-<code bash> 
-MariaDB [emails]> UPDATE users SET userLastName="Jones",userEmailAddress="janejones@example.com" WHERE userID=2; 
-</code> 
- 
----- 
  
  • linux_wiki/perform_simple_sql_queries_against_a_database.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)