SQLite Forum

Improve sqlite3_column_name() return value documentation
Login
> 1. I used AS in my SQL code.
> 2. I used SELECT *
> 
> I don't want programs depending on column names for anything else.

Then the SQL standard is not your friend. SQL-92 says in 7.9 9:

>    a) If the i-th `<derived column>` in the `<select list>` specifies
>      an `<as clause>` that contains a `<column name>` C, then the
>      `<column name>` of the i-th column of the result is C.
>
>    b) If the i-th `<derived column>` in the `<select list>` does not
>      specify an `<as clause>` and the `<value expression>` of that
>      `<derived column>` is a single `<column reference>`, then the
>      `<column name>` of the i-th column of the result is C.
>
>    c) Otherwise, the `<column name>` of the i-th column of the `<query`
>      `specification>` is implementation-dependent and different
>      from the `<column name>` of any column, other than itself, of
>      a table referenced by any `<table reference>` contained in the
>      SQL-statement.

(`SELECT *` generates `<column reference>`s as in case b.)

Every SQL database must give predictable column names for direct column references.

And if it were necessary to write `SELECT x AS x, y AS y FROM ...`, such a database would not find many users.