SSL

SSL (Secure Sockets Layer) in SQL is a security protocol used to establish encrypted and secure communication between the SQL server and the client. It uses certificates to authenticate and encrypt the data being transmitted, protecting the data from unauthorized access and eavesdropping.

Example

SHOW VARIABLES LIKE '%ssl%';

Output

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_openssl | YES |
| have_ssl | YES |
+---------------+-------+

Explanation

The above SQL code checks if the MySQL server has SSL configured or not. The output ‘YES’ for both variables indicates that SSL is configured and enabled for the server.

Example

CREATE USER tech WITH PASSWORD 'password123';
GRANT CONNECT ON DATABASE dbname TO tech;

Output

CREATE ROLE
GRANT

Explanation

In the above example, we first create a new user named ‘tech’ with a password ‘password123’. Next, we grant this user the ‘CONNECT’ privilege on the database called ‘dbname’. This allows the user ‘tech’ to establish a connection with the database. The PostgreSQL server responses with ‘CREATE ROLE’ after the successful creation of the new user. The ‘GRANT’ response indicates that the permission granting operation completed successfully.

Example

SELECT *
FROM Employees
WHERE FirstName = 'John' AND LastName = 'Doe'

Output

| EmployeeID | FirstName | LastName | JobTitle |
|------------|-----------|----------|--------------|
| 1 | John | Doe | Site Manager |

Explanation

The above SQL script performs a basic query on an imaginary ‘Employees’ table to fetch the record of an employee whose first name is ‘John’ and last name is ‘Doe’. The output returns a single record based on the specified criteria.

Example

SELECT employee_id, last_name, salary
FROM employees
WHERE department_id = 30;

Output

EMPLOYEE_ID | LAST_NAME | SALARY
------------|-----------|--------
114 | Raphaely | 11000
115 | Khoo | 3100
116 | Baida | 2900
117 | Tobias | 2800
118 | Himuro | 2600
119 | Colmeres | 2500

Explanation

This SQL statement selects the columns employee_id, last_name, and salary from the employees table for those records where the department_id is 30.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.