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/05/20 23:08]
billdozor [Basics of SQL: Add,Remove,Modify]
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: 
-  * server2.example.com (192.168.1.151) -> Database here 
- 
-**Previous Sections Completed** 
-  * [[linux_wiki:install_and_configure_mariadb|Install and Configure MariaDB]] 
-  * [[linux_wiki:create_a_simple_database_schema|Create a Simple Database Schema]] 
- 
----- 
- 
-====== 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 two new rows/entries into a table (two methods) 
-<code bash> 
-# Values method 
-MariaDB [emails]> INSERT INTO users (userFirstName,userLastName,userEmailAddress) VALUES ("Robert","Jones","rjones@example.com"); 
- 
-# Set method 
-MariaDB [emails]> INSERT INTO users set userFirstName="Jane", userLastName="Smith", userEmailAddress="jsmith@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 Robert Jones to change the email address 
-<code bash> 
-MariaDB [emails]> UPDATE users SET userEmailAddress="robert.jones@example.com" WHERE userID=1; 
-</code> 
- 
----- 
  
  • linux_wiki/perform_simple_sql_queries_against_a_database.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)