SQL Keywords

SQL ACCESSIBLE

What is the SQL ACCESSIBLE keyword used for?

ACCESSIBLE is a reserved SQL keyword used to express or reserve the concept of restricting which database objects can call a routine or to mark the word for future language extensions.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL ACCESSIBLE: Oracle: full ACCESSIBLE BY clause support. MySQL: keyword is reserved only; no functionality. MariaDB: reserved. IBM Db2: reserved. PostgreSQL, SQL Server, SQLite, Snowflake: not reserved, not implemented.

SQL ACCESSIBLE Full Explanation

ACCESSIBLE appears in the SQL standard and several database systems as a way to describe routine visibility. In Oracle, the phrase ACCESSIBLE BY is appended to a PL/SQL function, procedure, or package element to explicitly list the callers that are allowed to invoke that routine. In MySQL the word is currently reserved for future use, which means you cannot use ACCESSIBLE as an unquoted identifier (table, column, or alias name) without quoting it. Other engines such as IBM Db2 also reserve the keyword for similar reasons. Because it is reserved, the primary impact today (outside of Oracle PL/SQL) is on naming: developers must quote the identifier if they want to use the word in schemas, otherwise the parser raises a syntax error.

SQL ACCESSIBLE Syntax

-- Oracle PL/SQL routine visibility
FUNCTION func_name RETURN NUMBER
ACCESSIBLE BY (allowed_unit [, allowed_unit]...);

-- Using the word as an identifier in MySQL (quoted)
CREATE TABLE `accessible` (
  id INT PRIMARY KEY
);

SQL ACCESSIBLE Parameters

Example Queries Using SQL ACCESSIBLE

-- 1. Oracle: limit a function so only specific packages can call it
CREATE OR REPLACE PACKAGE emp_sec_pkg AS
  FUNCTION get_salary (p_emp_id NUMBER)
    RETURN NUMBER
    ACCESSIBLE BY (hr_pkg, pay_pkg);
END emp_sec_pkg;
/

-- 2. MySQL: attempt to use reserved word as identifier (fails)
CREATE TABLE accessible (id INT);
-- Error: You have an error in your SQL syntax; check the manual...

-- 3. MySQL: correct use with quoting
CREATE TABLE `accessible` (
  id INT PRIMARY KEY
);

-- 4. Querying the quoted table
SELECT id FROM `accessible`;

Expected Output Using SQL ACCESSIBLE

  • Oracle example compiles. Only hr_pkg or pay_pkg can call get_salary; any other unit raises ORA-06550 at compile time.
  • Second statement fails with a syntax error because ACCESSIBLE is reserved.
  • Third statement succeeds because the identifier is quoted.
  • Fourth statement returns table rows normally.

Use Cases with SQL ACCESSIBLE

  • Hardening PL/SQL APIs by explicitly listing which packages or procedures may call a sensitive routine.
  • Ensuring identifier compatibility when a schema must include the word ACCESSIBLE by quoting it.
  • Preparing codebases for future SQL standard features that might rely on the ACCESSIBLE keyword.

Common Mistakes with SQL ACCESSIBLE

  • Forgetting that ACCESSIBLE is reserved in MySQL and using it unquoted as a column or table name.
  • Assuming ACCESSIBLE BY will work in databases other than Oracle; most engines do not yet implement the clause.
  • Confusing ACCESSIBLE BY with privilege GRANT statements. ACCESSIBLE BY is a compile-time visibility check, not a runtime permission system.

Related Topics

ACCESS CONTROL, GRANT, INVOKER RIGHTS, DEFINER RIGHTS, SQL SECURITY, IDENTIFIER QUOTING

First Introduced In

Oracle Database 11g Release 2 (11.2) introduced ACCESSIBLE BY; MySQL 5.7 reserved the keyword.

Frequently Asked Questions

What does ACCESSIBLE BY do in Oracle?

ACCESSIBLE BY lets you list exactly which packages, procedures, or functions can invoke the routine. Calls from other units cause a compile error, adding compile-time security.

Can I use ACCESSIBLE as a column or table name in MySQL?

Yes, but you must quote it because the word is reserved. Example: CREATE TABLE `accessible` (id INT);

Is ACCESSIBLE supported in PostgreSQL or SQL Server?

No. These systems neither reserve the keyword nor implement the ACCESSIBLE BY clause.

Does ACCESSIBLE BY replace database privileges?

No. It complements them. ACCESSIBLE BY works at compile time for PL/SQL code, while GRANT/REVOKE handle runtime permissions.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!