Every table, column, schema, and index needs a name. In SQL those names are identifiers. Db2 for z/OS distinguishes ordinary identifiers from delimited identifiers, and it resolves short names into full names through qualification—especially schema qualification. This lesson shows how to name objects correctly and how Db2 decides which EMPLOYEE table you meant.
An identifier is a user-supplied name in SQL. You use identifiers for schemas, tables, views, indexes, columns, aliases, constraints, correlation names, and many other objects. Keywords like SELECT are not identifiers—you cannot use a reserved keyword as an ordinary identifier unless you delimit it (and even then, standards often forbid the practice).
| Form | Example | Notes |
|---|---|---|
| Ordinary | EMPLOYEE | Folded to uppercase; no spaces; standard characters |
| Delimited | "Employee Name" | Double quotes; can preserve case / special characters |
| Qualified | HR.EMPLOYEE | Schema plus object name |
| Column qualified | E.EMP_ID | Correlation or table qualifier for a column |
An ordinary identifier follows Db2’s ordinary naming rules. In practical beginner terms:
So employee, Employee, and EMPLOYEE written as ordinary identifiers all refer to EMPLOYEE. Catalog displays and EXPLAIN output typically show the uppercase form. Mainframe shops often standardize on ordinary uppercase names in DDL for predictability.
123456789CREATE TABLE HR.EMPLOYEE ( EMP_ID CHAR(6) NOT NULL, EMP_NAME VARCHAR(40) NOT NULL, DEPT_ID CHAR(3) ); SELECT emp_id, emp_name FROM hr.employee WHERE dept_id = 'A01';
In that example, ordinary identifiers are folded: the SELECT still targets HR.EMPLOYEE. Consistency in typing helps humans even when Db2 folds case.
A delimited identifier is enclosed in double quotation marks. Delimiting lets you use names that ordinary rules reject—spaces, certain special characters, or mixed case that you want preserved. Delimited identifiers are case-sensitive as written.
1234567CREATE TABLE HR."Employee Info" ( "Emp Id" CHAR(6) NOT NULL, "Emp Name" VARCHAR(40) NOT NULL ); SELECT "Emp Id", "Emp Name" FROM HR."Employee Info";
Most Db2 for z/OS application standards prefer ordinary identifiers. Use delimited names when you must—not as a default style.
Single quotes mark string literals. Double quotes mark delimited identifiers. Confusing them causes confusing errors.
12345-- Predicate compares column DEPT_ID to string literal 'A01' WHERE DEPT_ID = 'A01' -- Delimited identifier reference (a name), not a character string FROM HR."EMPLOYEE"
A qualified name includes one or more qualifiers that locate the object in a namespace. The most important beginner form is:
123456schema-name.object-name Examples: HR.EMPLOYEE PAYROLL.PAY_STUB SYSIBM.SYSTABLES
Qualification removes ambiguity when two schemas each have an EMPLOYEE table. It also documents intent for readers of your SQL. In multi-team subsystems, unqualified names are a common source of “works in my session, fails in yours” problems.
Columns can be qualified by table name or by a correlation name (alias) to resolve ambiguity in joins:
1234SELECT E.EMP_ID, D.DEPT_NAME FROM HR.EMPLOYEE E JOIN HR.DEPARTMENT D ON E.DEPT_ID = D.DEPT_ID;
Here E and D are correlation names. E.EMP_ID means “EMP_ID from the EMPLOYEE side of the join.” Qualification is not only about schemas—it also clarifies columns whenever more than one table is in scope.
A schema is a logical collection of named objects. The schema name is the qualifier used when objects are created and referenced. Objects are assigned to a schema at CREATE time—either because you wrote an explicit qualifier or because Db2 applied a default qualifier.
Writing HR.EMPLOYEE is explicit. Db2 does not guess. This is the clearest style for production SQL, reports, and training examples when the schema is known.
If you write FROM EMPLOYEE with no schema, Db2 must resolve the unqualified name. Rules depend on object type and context, but for many table/view references the CURRENT SCHEMA special register participates as the default qualifier. Older and alternate paths also involve the plan or package owner’s authorization ID as a default schema in some situations. Exact resolution details are documented in IBM’s sections on qualification of unqualified object names—bookmark that topic as you advance.
12345678-- Session default schema set to HR (example) SET CURRENT SCHEMA = 'HR'; -- Resolves using CURRENT SCHEMA -> HR.EMPLOYEE (typical case) SELECT EMP_ID FROM EMPLOYEE; -- Still unambiguous regardless of CURRENT SCHEMA SELECT EMP_ID FROM HR.EMPLOYEE;
Beginners often meet two registers early: CURRENT SCHEMA influences default schema qualification for unqualified object names, while CURRENT SQLID relates to the authorization ID used for privilege checking and ownership behaviors. They can differ. Later lessons cover authorization IDs and current registers in depth; for now, remember that “who I am for security” and “which schema is my default” are related but not identical ideas.
Db2 reserves schemas for system use (for example schemas starting with SYS in important ways, and others described in IBM docs). Do not create application objects in system schemas. SYSIBM catalog tables are for reading metadata with proper authority—not for casual CREATE experiments.
Embedded SQL uses the same identifier rules inside EXEC SQL. Host variables are marked with a colon and follow host-language naming, not SQL identifier folding rules for the COBOL side. Object names in the SQL text still follow SQL identifier rules.
123456EXEC SQL SELECT EMP_NAME INTO :WS-EMP-NAME FROM HR.EMPLOYEE WHERE EMP_ID = :WS-EMP-ID END-EXEC.
Names are like labels on toy boxes. A plain label EMPLOYEE is written in big capital letters so everyone reads it the same. A fancy label in quotes can say "My Cool Toys" with spaces, but then you must always say it exactly that fancy way. Putting HR. in front is like saying “the EMPLOYEE box in the HR classroom,” so you do not open the Finance classroom’s box by mistake. If you only say EMPLOYEE, the teacher looks at which classroom you are standing in (your current schema) and picks that box.
1. What is an ordinary SQL identifier in Db2?
2. How do you write a delimited identifier?
3. What does HR.EMPLOYEE mean as a qualified table name?
4. If you write SELECT * FROM EMPLOYEE with no schema, what must Db2 do?
5. Why might a site prefer ordinary uppercase identifiers?