SQL (Structured Query Language) is a query language for relational databases. It reads and modifies records, defines table structures and manages other database objects. Joomla uses SQL through its database access layer.
SQL and database systems
SQL is a language, while MySQL and MariaDB are database management systems that execute queries. Syntax and capabilities vary by system and version. A query written for one system is not necessarily fully portable to another.
Main operations
| Operation | Purpose |
|---|---|
| SELECT | Read records matching conditions. |
| INSERT | Add records. |
| UPDATE | Modify existing records. |
| DELETE | Remove records. |
| CREATE and ALTER | Create and change object structures. |
JOIN combines data from several tables. For example, an article can be matched to its category by an identifier. A primary key identifies a row, while indexes speed up suitable queries. Unnecessary indexes consume space and add overhead to writes.
SQL in Joomla
When a page is requested, Joomla’s PHP code reads data and generates a response. Extension developers use Joomla Database API, including its query builder, parameter binding and table naming facilities. The placeholder prefix #__ is replaced with the installation’s actual table prefix.
Pass user-supplied values as bound parameters rather than concatenating them into SQL. Table and column names need separate validation and correct quoting. Parameterisation helps prevent SQL injection but does not replace permission checks.
Changes and transactions
Before a bulk UPDATE or DELETE, inspect the same conditions with SELECT and make a backup. Without WHERE, a query can affect the entire table. Transactions group related changes, but rollback support depends on the table engine and operation. Schema changes may cause an implicit commit.
Summary
SQL enables Joomla to work with stored data. Safe queries need precise conditions, parameter binding, access controls and backups before substantial changes.