Sub topic 2
FreeSQL: SQL in the browser with no install
This chapter assumes that you know basic SQL, including SELECT, INSERT, and CREATE TABLE. You should also understand that a database client sends SQL to a database server. FreeSQL provides both parts through a web browser, so you do not need to install Oracle Database, a client program, or a container.
What FreeSQL provides
FreeSQL is a browser-based Oracle SQL environment. You open the site, enter SQL in a worksheet, run it against an Oracle database, and inspect the results on the same page.
A worksheet is an editor for SQL statements. A script is a saved collection of statements that you can run again. Your objects, such as tables and views, belong to the database schema assigned to your workspace.
FreeSQL is useful when your goal is to practice SQL syntax quickly:
- You do not need administrator access on your computer.
- You do not need to configure a listener, port, service name, or wallet.
- You can run examples from a browser on many computers.
- You can save scripts so that your work is available later.
- You can experiment without managing a local database installation.
FreeSQL is less suitable when you need operating-system access, database configuration privileges, a custom Oracle version, or a repeatable local environment for an application.
Open a worksheet and run a script
Open the FreeSQL site in your browser and sign in or create an account if the site requests one. The exact button names can change, but look for a worksheet, SQL editor, or script area.
Paste a small script into the editor. This example creates a table, inserts one row, and queries the row.
CREATE TABLE practice_note (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
body VARCHAR2(200) NOT NULL
);
INSERT INTO practice_note (body)
VALUES ('Hello from FreeSQL');
COMMIT;
SELECT id, body
FROM practice_note;Run the script using the worksheet's run command. The result should contain one row. The CREATE TABLE statement is DDL, or data definition language. DDL changes the database structure. The INSERT statement is DML, or data manipulation language. DML changes stored data. COMMIT makes the inserted row part of the saved transaction.
If the editor supports running only the current statement, place the cursor inside the SELECT statement and run that statement separately. To run the complete example, use the command for running a script or all statements.
Save and rerun your work
Save the script with a descriptive name, such as 01_practice_note.sql. Keep setup statements and test queries together when you want a complete example that another learner can understand.
A script that creates a table normally succeeds only once. Running it again may produce an error because PRACTICE_NOTE already exists. You can either use a new table name or remove the table before recreating it.
DROP TABLE practice_note PURGE;
CREATE TABLE practice_note (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
body VARCHAR2(200) NOT NULL
);
INSERT INTO practice_note (body)
VALUES ('A repeatable FreeSQL example');
COMMIT;
SELECT id, body
FROM practice_note;DROP TABLE removes the table and its data. PURGE also removes the table from the recycle bin. Use this form only for disposable practice objects.
Understand the boundary of the environment
FreeSQL hides most connection details. You usually do not choose a host, port, service name, or pluggable database. The service selects an Oracle schema for your work.
This convenience also limits what you can practice. You may not have permission to create users, change database parameters, inspect the operating system, or test client configuration. An error such as ORA-01031: insufficient privileges can therefore be expected rather than a problem with your SQL.
FreeSQL is a good first choice for:
- Short SQL exercises
- Saved demonstrations
- Testing queries and table definitions
- Learning Oracle SQL features without local setup
Use a local container when you need control over the database server. Use an Autonomous Database when you need a persistent cloud database and managed connectivity.
Exercise
You ran the example twice and received an error that PRACTICE_NOTE already exists. What caused the error, and what two changes can you make?
Show answer
The first run created the table, so the second CREATE TABLE statement conflicts with the existing object. You can use a different table name, or run DROP TABLE practice_note PURGE before recreating it.