lunedì 29 agosto 2011

Mysql: parole riservate

Alcuni termini, se assegnati ai nomi dei campi, producono un errore se non vengono richiamati con escape.

Es:
SELECT * FROM database WHERE ... → Errore: "You have an error in your SQL syntax"
SELECT * FROM `database` WHERE ... → Esatto

Per evitare problemi, è bene evitare le seguenti parole:

accessible, add, all, alter, analyze, and, as, asc, asensitive, before, between, bigint, binary, blob, both, by, call, cascade, case, change, char, character, check, collate, column, condition, constraint, continue, convert, create, cross, current_date, current_time, current_timestamp, current_user, cursor, database, databases, day_hour, day_microsecond, day_minute, day_second, dec, decimal, declare, default, delayed, delete, desc, describe, deterministic, distinct, distinctrow, div, double, drop, dual, each, else, elseif, enclosed, escaped, exists, exit, explain, false, fetch, float, float4, float8, for, force, foreign, from, fulltext, grant, group, having, high_priority, hour_microsecond, hour_minute, hour_second, if, ignore, in, index, infile, inner, inout, insensitive, insert, int, int1, int2, int3, int4, int8, integer, interval, into, is, iterate, join, key, keys, kill, leading, leave, left, like, limit, linear, lines, load, localtime, localtimestamp, lock, long, longblob, longtext, loop, low_priority, master_ssl_verify_server_cert, match, maxvalue, mediumblob, mediumint, mediumtext, middleint, minute_microsecond, minute_second, mod, modifies, natural, not, no_write_to_binlog, null, numeric, on, optimize, option, optionally, or, order, out, outer, outfile, precision, primary, procedure, purge, range, read, reads, read_write, real, references, regexp, release, rename, repeat, replace, require, resignal, restrict, return, revoke, right, rlike, schema, schemas, second_microsecond, select, sensitive, separator, set, show, signal, smallint, spatial, specific, sql, sqlexception, sqlstate, sqlwarning, sql_big_result, sql_calc_found_rows, sql_small_result, ssl, starting, straight_join, table, terminated, then, tinyblob, tinyint, tinytext, to, trailing, trigger, true, undo, union, unique, unlock, unsigned, update, usage, use, using, utc_date, utc_time, utc_timestamp, values, varbinary, varchar, varcharacter, varying, when, where, while, with, write, xor, year_month, zerofill

Nessun commento:

Posta un commento