# info > DBI::SQL::Nano

---
type: CommandReference
command: DBI::SQL::Nano
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- Force Nano parser: `BEGIN { $ENV{DBI_SQL_NANO} = 1 }`
- Parse SELECT: `DBI::SQL::Nano::Statement->new("SELECT bar,baz FROM foo WHERE qux=1")`
- Parse INSERT: `DBI::SQL::Nano::Statement->new("INSERT INTO t (a,b) VALUES (1,'x')")`
- Parse UPDATE: `DBI::SQL::Nano::Statement->new("UPDATE t SET a=2 WHERE b='y'")`
- Parse DELETE: `DBI::SQL::Nano::Statement->new("DELETE FROM t WHERE a=1")`
- Parse CREATE TABLE: `DBI::SQL::Nano::Statement->new("CREATE TABLE t (id INT, name VARCHAR(40))")`
- Parse DROP TABLE: `DBI::SQL::Nano::Statement->new("DROP TABLE IF EXISTS t")`
- Use with DBD drivers: automatically activated when `SQL::Statement` is absent

## Name
DBI::SQL::Nano — a very tiny SQL engine

## Synopsis
perl
BEGIN { $ENV{DBI_SQL_NANO} = 1 }   # force Nano over SQL::Statement
use DBI::SQL::Nano;
use Data::Dumper;
my $stmt = DBI::SQL::Nano::Statement->new(
    "SELECT bar,baz FROM foo WHERE qux = 1"
) or die "Couldn't parse";
print Dumper $stmt;
## Supported SQL
- `SELECT <cols> FROM <table> [WHERE <predicate>] [ORDER BY <col> [ASC|DESC]]` — Retrieve rows; `*` selects all columns; single table, no JOINs.
- `INSERT INTO <table> [(<col_list>)] VALUES (<val_list>)` — Insert one row; values may be placeholders (`?`), numbers, column names, `NULL`, or single‑quoted strings.
- `UPDATE <table> SET <col>=<val> [,...] WHERE <predicate>` — Update rows; WHERE clause required.
- `DELETE FROM <table> [WHERE <predicate>]` — Delete rows.
- `CREATE TABLE <table> <col_def_list>` — Column types and constraints are ignored but recommended for portability.
- `DROP TABLE [IF EXISTS] <table>` — No error if table missing when `IF EXISTS` given.

**WHERE predicate**: `[NOT] <col/val> <op> <col/val>`. Only one predicate supported (no AND/OR). Operators: `<`, `>`, `>=`, `<=`, `=`, `<>`, `LIKE`, `CLIKE` (case‑insensitive LIKE), `IS`. Wildcards `%` and `_` allowed in quoted strings for `LIKE`/`CLIKE`. No escaped quotes or embedded commas in strings—use placeholders.

## Table Interface
When subclassing `DBI::SQL::Nano::Statement`, the table object returned by `open_table()` must implement:
- `drop($$)` — Drop the table.
- `fetch_row($$$)` — Fetch next row as arrayref.
- `push_row($$$)` — Insert a row.
- `push_names($$$)` — Store column names.
- `truncate($$)` — Delete all rows.
- `seek($$$$)` — Position cursor (for updates, deletes).

Inherit from `DBI::SQL::Nano::Table` or `SQL::Eval::Table` to get base implementations.

## Examples
perl
# Force Nano engine and parse a SELECT
BEGIN { $ENV{DBI_SQL_NANO} = 1 }
use DBI::SQL::Nano;
use Data::Dumper;

my $sql = "SELECT id, name FROM users WHERE age >= 18 ORDER BY name DESC";
my $stmt = DBI::SQL::Nano::Statement->new($sql)
    or die "Parse error: $DBI::SQL::Nano::Statement::errstr";
print Dumper $stmt;
## See Also
- [DBI](https://metacpan.org/pod/DBI)
- [SQL::Statement](https://metacpan.org/pod/SQL::Statement)
- [DBD::DBM](https://metacpan.org/pod/DBD::DBM)
- [DBD::CSV](https://metacpan.org/pod/DBD::CSV)
- [DBD::AnyData](https://metacpan.org/pod/DBD::AnyData)
- [DBD::Excel](https://metacpan.org/pod/DBD::Excel)