Skip to content
DB2 & data

SQL

The language used to query and change relational data. The same SQL used everywhere else, running against mainframe tables.

Also written Structured Query Language

SQL, Structured Query Language, is how relational data is read and written. On the mainframe it works against DB2 tables, and the language itself is the standard one used across the industry.

The core statements are the familiar four. SELECT retrieves rows, with conditions, ordering, grouping and joins across tables. INSERT adds rows. UPDATE changes existing ones. DELETE removes them. Alongside those sit the statements that define tables, indexes and views.

The thing that differs on z/OS is not the syntax but the context. SQL can be run interactively for enquiry and testing, and it can be embedded directly inside a COBOL program so that business logic and data access sit in the same source file. Embedded SQL goes through an extra preparation step before the program can run.

Because these systems are large, how a query is written has consequences. A statement that scans a table of two billion rows rather than using an index will work correctly and take a very long time, and learning to notice the difference is part of the job.

Browse all 115 terms

Learn this properly.

Use SQL for real in Mainframe101, in your browser, with Zed beside you. Join the waitlist.

Early access and updates. No spam, unsubscribe any time.