I am trying to load 1,000,000 lines of data into AgensGraph.
It is simple data with fake user profiles, and I named the label as "user".
However, ERROR statement popped out, and I believe it is because the word "user"
is reserved as one of the reserved words of AgensGraph. When I changed the word to "person", it creates vertexes without any problem.
agraph=# LOAD FROM vlabel_user AS user CREATE (a:user=row_to_json(user)::jsonb);
ERROR: syntax error at or near "user"
LINE 1: LOAD FROM vlabel_user AS user CREATE (a:user=row_to_json(use...
agraph=# LOAD FROM vlabel_user AS person CREATE (a:person=row_to_json(person)::jsonb);
GRAPH WRITE (INSERT VERTEX 1000000)
After I found this out, I wonder whether there are other words besides "user" that I cannot use. I couldn't find any information through the Google, so I
am asking others' help.
Right, "user" is reserved word. agensgraph is based on postgresql and supports all SQL queries available in postgresql. For this reason, all reserved words in postgresql are also reserved words in agensgraph. (The reserved words for postgresql can be found here.)
If you want to use reserved words, enclose the identifier in double-quotes(e.g. : "user").
Additionaly, "MATCH" and "RETURN" are added to reserved keyword in AgensGraph for Cypher grammar.
Related
I have a PostgreSQL database with many different tables and relations. There is one table named User. In our project, when people join the product, they can optionally provide FirstName and LastName. In the User table, it is kept under one column "name", so it looks like this: "Alex Smith"(exactly one space between them). There was a little bug, that if a user would not provide a FirstName or LastName, JavaScript would've inserted undefined. Our base looks like this:
If there is no FirstName, it is "undefined LastName", or the other way, or "undefined undefined". Now the bug is solved, but the base needs to be cleaned up a little bit. There are thousands of users with undefined FirstNames or LastNames or both. What I was trying to do, is to write a PostgreSQL query, which goes recursively over the table User and checks if there is "undefined" in a column and replaces undefined with an empty string "".
My problem is that I need to check and replace only undefined, if there is "undefined Smith", only undefined should be replaced with an empty string. I've checked the official documentation, and in StackOverflow, I couldn't find any similar case. If anybody will have a clue, would appreciate it a lot.
Thanks in advance.
Look up the Postgres String Functions Trim and Replace.
Using them together is what you are looking for. Something like (see example)
update user
set name = trim(replace(name, 'undefined',''));
Warning: USER is a very bad table name; it is a reserved word by by both Postgres and SQL Standard. While you can get away with using it in other than a predefined meaning, Postgres developers would be well within their writes to make in an invalid name at any time. Never use reserved words nor data types as DB object names.
Can anybody point me to a page listing all the reserved words in Hive?
There are many questions here aimed to using the reserved words as a column or table names after such columns or tables were created. My question is about how to avoid creating such columns or tables.
If you google "some_DBMS reserved words", the first hit is the official page.
I.e., here it's for Oracle, here for Postgres, here for MySQL, etc. But not for Hive.
Here is the only page I was able to find, but it's inaccurate - it does not include the DIV keyword, which is empirically found to be reserved.
I was looking into the code and found it to be in:
/src/java/org/apache/hadoop/hive/ql/parse/HiveLexerParent.g
https://github.com/apache/hive/blob/rel/release-3.1.0/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
You can get reserve keyword of hive:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL
i have a table called ORDER, when i try to query it using
select * from Order
i get the error 'invalid query'
how to do access this table please?
thank you
Step 1
Don't ever used reserved words for object (or column) names.
SQL 1992 Standard (search for <reserved word>)
SQL Server reserved words
MySQL reserved words
DB2 reserved words
Step 2
If you've inherited such a thing that you are not able to change, then you need to use "quoted identifiers".
I advocate
SELECT *
FROM "Order"
As it is a standard identifier, so will work better across platforms.
ORDER is a reserved word in SQL. Put double quotes around it:
select * from "Order"
And also, I personally think ORDERS is a better name. (Because several orders are stored in the table.)
Late edit: List of reserved words, in different versions of the SQL standard:
http://developer.mimer.com/standard/reservedwords/sql-reserved-words.tml
It's generally a good idea to not use reserved words for database object names (tables, views & etc.). Sometimes you just got to deal with it though. The below query should work for you.
select * from [Order]
Just put the brackets around the table name.
Hope this helps!
I have a problem with sql ant taks with my build.xml.
I use task in ant and creating a table with column name "rem" fails. I am guessing this is a reserved word in Oracle. However, I have two questions regarding this issue:
This problem diesn't occur in sqlplus. i.e.: It lets me create a table with column name "rem".
Should I be concerened about reserved words that aren't of Oracle. For example: "go" in mysql?
Thnak you.
I don't think you need to worry about MySQL reserved words unless you are intending on using both RDBMS.
However, to address your second point first:
While cagcowboy's answer tells you how to fix the problem I can only ask that you do not do this.
I something has to be enclosed in double quotes then you have to remember to do that everywhere. Some UIs ( e.g. Toad ) require special options to be initialised.
Effectively it's a massive amount of hassle and as Dems and Davd Faber have commented can be massively confusing.
Incidentally go does seem to be a reserved work in Oracle, no idea what it does though.
To address your first bullet point rem isn't actually a reserved word in Oracle - only SQL*Plus- and creating a table with rem as a column name works because of this. Your specific problem must be a something to do with ant.
Try putting the column in double quotes...
"REM"
If I do a full text search on SQL 2008, can I get a pointer ( File , or Database) so that I don't have to load the 100MB memo field to by Business Object and do search again ?
It does not appear that SQL Server 2008 supports the retrieval of offset pointers to the found keywords within the memo field.
Full text search does not search the memo fields, but searches an index that specifies which keywords are in which documents. The information about where these words appear within each document does not seem to be available in the full text search index.
Microsoft offers a type of query called sys.dm_fts_index_keywords_by_document. With it, you can enable the following use cases:
“I want to know how many keywords the full-text index contains”
“I want to know if a keyword is part of a given doc/row”
“I want to know how many times a keyword appears in the whole full-text index” (sum(occurrence_Count) where keyword=……)
“I want to know how many times a keyword appears in a given doc/row”
“I want to know how many keywords a given doc/row contains”
“I want to retrieve all the keywords belonging to a given doc/row”
However, scenarios not covered in this release:
“I want to know the offset (word or byte) of a given keyword in a given doc/row”
“I want to know the distance (in words) between two keywords per a given doc/row”
Sources:
http://technet.microsoft.com/en-us/library/cc721269.aspx#_Toc202506233
http://msdn.microsoft.com/en-us/library/cc280607.aspx