Index Ai Academy
Glossary · Phase 7 · Software engineering

SQL injection

An attack where text pasted into a database query changes the query itself. Placeholders prevent it.

The attacker's quote mark ended the string early and added OR '1'='1', which is always true. That's SQL injection, one of the most damaging and common security bugs ever found. With a placeholder (? in SQLite, %s in many Postgres drivers), the value travels separately from the SQL. The database never treats it as code, whatever characters it contains.

Try it now

SQL runs in this order, not the order you write it, which explains many confusing errors.

Learn it properly

Databases and SQL · Store, query and join data with the language every database speaks. About 40 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write