- 13-Jan-2023 08:23 pm
- 54 Viewed
- 0 Comments
SQL (Structured Query Language) is a programming language used to communicate with relational databases. Here are some examples to get you started with SQL in Oracle SQL Developer:
- Create a new connection:
In Oracle SQL Developer, click on the "Connections" icon in the navigation panel. Then, click on the green plus sign to create a new connection. Enter the connection details (e.g. username, password, hostname) and click "Test" to test the connection. If the test is successful, click "Save" to save the connection.
- Create a table:
To create a new table in a database, use the following SQL syntax:
CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, ... ); |
For example, to create a table called "Employees" with columns "ID", "Name", and "Salary", you would use the following SQL statement:
CREATE TABLE Employees ( ID integer, Name varchar(255), Salary integer ); |
- Insert data into a table:
To insert data into a table, use the following SQL syntax:
INSERT INTO table_name (column_name1, column_name2, ...) VALUES (value1, value2, ...); |
For example, to insert a row into the "Employees" table with ID 1, Name "John Smith", and Salary 45000, you would use the following SQL statement:
INSERT INTO Employees (ID, Name, Salary) VALUES (1, 'John Smith', 45000); |
- Select data from a table:
To retrieve data from a table, use the following SQL syntax:
SELECT column_name1, column_name2, ... FROM table_name; |
For example, to select all columns from the "Employees" table, you would use the following SQL statement:
SELECT * FROM Employees; |
- Update data in a table:
To update data in a table, use the following SQL syntax:
UPDATE table_name SET column_name1 = value1, column_name2 = value2, ... WHERE condition; |
For example, to update the salary of the employee with ID 1 to 50000, you would use the following SQL statement:
UPDATE Employees SET Salary = 50000 WHERE ID = 1; |
- Delete data from a table:
To delete data from a table, use the following SQL syntax:
DELETE FROM table_name WHERE condition; |
For example, to delete the employee with ID 1 from the "Employees" table, you would use the following SQL statement:
DELETE FROM Employees WHERE ID = 1; |
get started with SQL in Oracle SQL Developer!