Database Administrators
Q&A for database professionals who wish to improve their database skills
Latest Questions
10
votes
3
answers
2027
views
Is the keyword "ALIAS" actually used?
According to PostgreSQL 7.1 through 9.1 (now unsupported), `ALIAS` is listed as a reserved word, at least for SQL-99. Later versions do not show it - suggesting that it has been dropped as a reserved word. The old PostgreSQL docs do say *"the presence of a key word does not indicate the existence of...
According to PostgreSQL 7.1 through 9.1 (now unsupported),
ALIAS
is listed as a reserved word, at least for SQL-99. Later versions do not show it - suggesting that it has been dropped as a reserved word. The old PostgreSQL docs do say *"the presence of a key word does not indicate the existence of a feature."* When aliasing a table or column I've seen AS
, but never ALIAS
.
Where is (or was) the SQL keyword ALIAS
used? Was it ever in-use or only ever reserved for future-use?
user4930
Jan 14, 2019, 03:29 PM
• Last activity: Feb 3, 2019, 08:30 AM
0
votes
1
answers
265
views
System-level way to enforce that reserved words may not be used for Oracle column names?
Is there a way in Oracle 12c to enforce that reserved words / keywords may not be used as column names? I am aware that it is not good practice to use keywords in this way. However from what we have observed, tables are able to be created with a column name of the reserved word "password" in our loc...
Is there a way in Oracle 12c to enforce that reserved words / keywords may not be used as column names? I am aware that it is not good practice to use keywords in this way. However from what we have observed, tables are able to be created with a column name of the reserved word "password" in our local Oracle, but the customer found that the table was was not being created on their Oracle environment.
A complication here is that the tables are being created by a Java application which uses Hibernate to create the tables and these are not simply DDL statements. I have seen the related question: https://dba.stackexchange.com/questions/148350/oracle-add-reserved-word-as-column-name and I realise that the use of reserved words is permitted inside quotes, but I was wondering is there an system level "strict" mode that prevents the creation of tables with reserved words?
Phil
(101 rep)
Oct 30, 2018, 02:30 PM
• Last activity: Oct 31, 2018, 09:54 AM
3
votes
4
answers
8433
views
MySQL similar name for status or type column
As status and type is reserved key in MySQL, I need a column name similar to status to identify the status of a row. I know there is way to ignore this problem but in different language and different framework it suddenly arise this problem in different way, so I need to ignore this word and need a...
As status and type is reserved key in MySQL, I need a column name similar to status to identify the status of a row.
I know there is way to ignore this problem but in different language and different framework it suddenly arise this problem in different way, so I need to ignore this word and need a similar word that sound almost same and can be understandable from the name.
The potential values for my use case are true/false. What do you suggest to name a Boolean column that defines the status of that row?
Here status is defining that row if it is active or inactive. And not every where I'm using status column for this purpose, Somewhere status column is defining if the status is pending, current, confirmed, applied, rejected, etc. Like this shorts of key.
M.A.K. Ripon
(101 rep)
Sep 21, 2017, 05:45 AM
• Last activity: Oct 4, 2017, 12:56 PM
-1
votes
1
answers
490
views
Why would SQL queries that use reserved words suddenly start causing problems?
In the past couple of days we have experienced issues with 3 different applications that have been running fine for several years. Errors #1 and #2 were caused by reserved words in SQL queries. I am fairly certain that is also the cause of Error #3, but I cannot be sure as I don't have the source co...
In the past couple of days we have experienced issues with 3 different applications that have been running fine for several years. Errors #1 and #2 were caused by reserved words in SQL queries. I am fairly certain that is also the cause of Error #3, but I cannot be sure as I don't have the source code. The databases for the three applications are all on the same instance of SQL Server. We are running SQL Server 2008 with no updates, and the last Windows update was in 2016. What could have caused these errors to suddenly start occurring?
Error details:
1. We have a Web Forms site that has been used daily (and not updated) for the past 6 years. Two days ago it suddenly started throwing a SQL timeout exception on one of its pages. In SSMS I tested the raw queries being used and they all ran in under 2 seconds. However I noticed that two of them used the reserved words "Status" and "Date" without square brackets. I added square brackets around the reserved words and re-uploaded the site, and that fixed the error.
2. Today users reported an issue with a report in an old MS Access Data Project. I tested the report myself and got a query timeout. The data source for the report is a table-valued function, which when I executed directly in SSMS completed in a matter of seconds. I examined the function body and saw that it used the reserved words "Priority" and "Timestamp". I added square brackets, altered the function, and voila, the report now opens with no errors.
3. We have an .asmx web service that has been used daily for the past 6 years. One of the methods is supposed to query a table and return a list of user logins and passwords. Yesterday it started returning an empty response object. I don't have the source code for the web service so I can't see the text of the query. However I can see that the table has columns named with the reserved words "User_ID" and "Password", and based on the pattern for errors #1 and #2 I would bet that that's the problem.
These queries have been running for years without problems. Why would they suddenly start causing problems? Is there perhaps a configuration in SQL Server that has been changed?
Hamzah
(1 rep)
Jul 21, 2017, 03:10 PM
• Last activity: Jul 22, 2017, 11:40 AM
15
votes
1
answers
2125
views
Why is "Lookup" colored as a function reserved word in SQL Server?
In SSMS 2208, the identifier "Lookup" is colored hot pink as if it were a function (same color as, say, "Power" or "Convert"). Why? I cannot find it in the [official list of reserved words](http://msdn.microsoft.com/en-us/library/ms189822.aspx). Searches on the web seem useless as there are an awful...
In SSMS 2208, the identifier "Lookup" is colored hot pink as if it were a function (same color as, say, "Power" or "Convert"). Why?
I cannot find it in the [official list of reserved words](http://msdn.microsoft.com/en-us/library/ms189822.aspx) . Searches on the web seem useless as there are an awful lot of "lookup" terms out there that have nothing to do with my question.
ErikE
(4355 rep)
Aug 17, 2012, 12:32 AM
• Last activity: Dec 7, 2015, 07:33 PM
3
votes
1
answers
3120
views
What problems would using the reserved keywords DATE and TIME as column names cause in Oracle?
`DATE` is an SQL Reserved Word and `TIME` is a PL/SQL Reserved Word in Oracle (listed in `SQL> HELP RESERVED WORDS`). What problems would using them as column names cause in Oracle? The database server runs: ![enter image description here][2] [1]: https://i.sstatic.net/NJURX.png [2]: https://i.sstat...
DATE
is an SQL Reserved Word and TIME
is a PL/SQL Reserved Word in Oracle (listed in SQL> HELP RESERVED WORDS
). What problems would using them as column names cause in Oracle?
The database server runs:

Franck Dernoncourt
(2093 rep)
Apr 28, 2015, 12:33 AM
• Last activity: Apr 28, 2015, 01:09 AM
2
votes
1
answers
1030
views
trigger can't access column loop
SSCCE: The following script: $ cat test.sql CREATE TABLE public.foo ( loop INTEGER ); CREATE OR REPLACE FUNCTION public.foo_fun(loop INTEGER) RETURNS BOOLEAN AS $$ SELECT TRUE; $$ LANGUAGE SQL; CREATE OR REPLACE FUNCTION public.foo_tr_fun() RETURNS TRIGGER AS $$ DECLARE fRV BOOLEAN; BEGIN SELECT pub...
SSCCE:
The following script:
$ cat test.sql
CREATE TABLE public.foo (
loop INTEGER
);
CREATE OR REPLACE FUNCTION public.foo_fun(loop INTEGER) RETURNS BOOLEAN AS $$
SELECT TRUE;
$$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION public.foo_tr_fun() RETURNS TRIGGER AS $$
DECLARE
fRV BOOLEAN;
BEGIN
SELECT public.foo_fun(NEW.loop) INTO fRV;
IF fRV THEN
RETURN NEW;
ELSE
RAISE EXCEPTION 'bar';
END IF;
END
$$ LANGUAGE plpgsql;
CREATE TRIGGER foo_tr AFTER INSERT OR UPDATE ON public.foo
FOR EACH ROW
EXECUTE PROCEDURE public.foo_tr_fun();
... which I run with:
psql -v ON_ERROR_STOP=1 --quiet -X -U some-user -d some-db -f test.sql
... when I then try to insert a row into
foo
(from psql
):
$ psql -U some-user some-db
psql (9.1.14)
Type "help" for help.
RegTAP=> SELECT * FROM public.foo;
loop
------
(0 rows)
RegTAP=> INSERT INTO public.foo(loop) VALUES(0);
ERROR: record "new" has no field "loop"
LINE 1: SELECT public.foo_fun(NEW.loop)
^
QUERY: SELECT public.foo_fun(NEW.loop)
CONTEXT: PL/pgSQL function "foo_tr_fun" line 5 at SQL statement
RegTAP=>
Marcus Junius Brutus
(3409 rep)
Sep 16, 2014, 09:38 PM
• Last activity: Sep 16, 2014, 10:30 PM
1
votes
1
answers
348
views
why is the name `loop` treated differently in PostgreSQL
I issue the following DDL: CREATE TABLE foo ( loopa INTEGER, loop INTEGER ); Then, examining the DDL in the server (using a client-side tool like [DbVisualizer][1] - sorry don't know the query to produce it directly) I see the following: CREATE TABLE foo ( loopa INTEGER, LOOP INTEGER ); Observe the...
I issue the following DDL:
CREATE TABLE foo
(
loopa INTEGER,
loop INTEGER
);
Then, examining the DDL in the server (using a client-side tool like DbVisualizer - sorry don't know the query to produce it directly) I see the following:
CREATE TABLE
foo
(
loopa INTEGER,
LOOP INTEGER
);
Observe the change in case for the column named
loop
but not for the one named loopa
. Looking at the list of SQL keywords loop
doesn't appear to be a keyword. Why then, this selective change?
This *seems* to be related to a problem I am having with a trigger trying to access a column loop
in a table where I get:
Exception in thread "main" org.postgresql.util.PSQLException: ERROR: record "new" has no field "loop"
(where I get the same error regardless of whether the code in the trigger function access the field as NEW.LOOP
or NEW.loop
)
***UPDATE***
The upper-casing *seems* to be an artifact of DbVisualizer. psql
shows:
psql (9.1.13)
Type "help" for help.
foo-test=> \dS+ foo
Table "test.foo"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
loopa | integer | | plain |
loop | integer | | plain |
Has OIDs: no
Yet this still doesn't explain why the PostgreSQL engine apparently doesn't allow my trigger to access NEW.loop
. When I rename the column (and the trigger code) to loopi
everything appears to work fine. So, there is likely something deeper at work here than just a DbVisualizer glitch. I'll try to create a SSCCE later.
***UPDATE 2***
A SSCCE for the trigger problem has been created here .
Marcus Junius Brutus
(3409 rep)
Sep 16, 2014, 07:59 PM
• Last activity: Sep 16, 2014, 10:30 PM
4
votes
1
answers
3734
views
What is the purpose of the keyword "ID" in PostgreSQL?
I'm new to PostgreSQL and I ran into problems using the following query: SELECT * FROM table1 WHERE ID = 1 > ERROR: column "id" does not exist LINE 2: WHERE ID = 1 where ID is a column I added via a GUI-tool. I then found out that ID is a [keyword][1] in my current version of PSQL and should be quot...
I'm new to PostgreSQL and I ran into problems using the following query:
SELECT * FROM table1 WHERE ID = 1
> ERROR: column "id" does not exist
LINE 2: WHERE ID = 1
where ID is a column I added via a GUI-tool.
I then found out that ID is a keyword in my current version of PSQL and should be quoted. But I can't recognize what is this ID for.
On the linked page there is the following notice: > It is important to understand before studying Table C-1 that the fact that a key word is not reserved in PostgreSQL (==true) does not mean that the feature related to the word is not implemented. So, ID is not marked as a PostgreSQL keyword and there seems to be a feature connected to it, but I can't find out which. SELECT ID itself turns into the same error message as posted above.
I then found out that ID is a keyword in my current version of PSQL and should be quoted. But I can't recognize what is this ID for.
On the linked page there is the following notice: > It is important to understand before studying Table C-1 that the fact that a key word is not reserved in PostgreSQL (==true) does not mean that the feature related to the word is not implemented. So, ID is not marked as a PostgreSQL keyword and there seems to be a feature connected to it, but I can't find out which. SELECT ID itself turns into the same error message as posted above.
32bitfloat
(647 rep)
Sep 11, 2012, 09:10 PM
• Last activity: Sep 11, 2012, 10:59 PM
Showing page 1 of 9 total questions