LANGUAGE
Example
Section titled “Example”CREATE TABLE employees ( ID INT NOT NULL, name VARCHAR (20) NOT NULL, salary FLOAT NOT NULL, start_date DATE, city VARCHAR (20), PRIMARY KEY (ID));
INSERT INTO employees (ID, name, salary, start_date, city)VALUES (1, 'John Doe', 75000, '2022-01-31', 'New York');
SELECT * FROM employees;Output
Section titled “Output” ID | name | salary | start_date | city----|----------|--------|------------|--------- 1 | John Doe | 75000 | 2022-01-31 | New YorkExplanation
Section titled “Explanation”The example demonstrates the syntax to create a table titled ‘employees’ in PostgreSQL. Following the table’s initialization, one record is inserted using the INSERT INTO statement. The record is then retrieved using the SELECT * FROM employees; query which fetches all records from the employees table. The output shows the returned record in tabulated format.
Example
Section titled “Example”SELECT FirstName, LastNameFROM EmployeesWHERE EmployeeID = 1;Output
Section titled “Output”FirstName | LastName--------- | --------John | SmithExplanation
Section titled “Explanation”The SQL statement selects and displays the first name and last name from the Employees table for the record where the EmployeeID is 1.
Example
Section titled “Example”SELECT SYSDATE Current_Date, TO_CHAR(SYSDATE, 'Month') Current_MonthFROM dual;Output
Section titled “Output”CURRENT_DATE CURRENT_MONTH24-MAR-22 MarchExplanation
Section titled “Explanation”The provided SQL code retrieves the current date and month using Oracle’s SYSDATE function. The TO_CHAR function then converts the date value to return just the name of the current month.