I have a problem when I try to grant role. My command is:
grant john.doe to john;
And I get the error:
ERROR: syntax error at or near "."
I am using postgres database.
if your role is indeed john.doe use
grant "john.doe" to john;
https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
SQL identifiers and key words must begin with a letter (a-z, but also
letters with diacritical marks and non-Latin letters) or an underscore
(_). Subsequent characters in an identifier or key word can be
letters, underscores, digits (0-9), or dollar signs ($). Note that
dollar signs are not allowed in identifiers according to the letter of
the SQL standard, so their use might render applications less
portable.
and further:
There is a second kind of identifier: the delimited identifier or
quoted identifier. It is formed by enclosing an arbitrary sequence of
characters in double-quotes (")
and lastly:
Quoted identifiers can contain any character, except the character
with code zero. (To include a double quote, write two double quotes.)
This allows constructing table or column names that would otherwise
not be possible, such as ones containing spaces or ampersands. The
length limitation still applies.
Also most Postgres guys advise avoiding "camelCase" or "Other.Nam3s" as identifiers...
Related
When running sqlpackage.exe for deployments, do string variables require quotes around the word? It seems to be running successfully both ways. What is the correct syntax?
Two options shown here:
/v:CompanyName=ABCD
/v:CompanyName="ABCD"
Resource: https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage?view=sql-server-ver15
#Jeroen Mostert is right. It's more related to the command line not only the SqlPackage.
If the string variable contains spaces equality signs, slashes, or anything else that would interfere with option syntax, the value must be surrounded in "quotes".
Here is the example blog: https://www.addictivetips.com/windows-tips/enter-file-or-folder-paths-with-spaces-in-command-prompt-on-windows-10/
If all of the following conditions are met, then quote characters on the command line are preserved:
No /S switch (Strip quotes)
Exactly two quote characters
No special characters between the two quote characters, where special is one of: & < >( ) # ^ |
There are one or more whitespace characters between the the two quote characters
The string between the two quote characters is the name of an executable file.
Ref: https://ss64.com/nt/syntax-cmd.html
HTH.
I want to make sure user input has:
Two letters at the start
And the support for any number of optional space characters following these two letters.
Additionally, if at least one space character is provided, optionally allow letters, digits or . characters after it.
Here's the expression I currently have:
[a-zA-Z][a-zA-Z] (?\\s+ (?a-zA-Z0-9.))
And here's my thinking:
[a-zA-Z][a-zA-Z] makes sure the input begins with at least two letters
(?\\s+ begins an optional statement. This optional statement must start with at least one space (I'm on windows which is why I have two slashes).
(?a-zA-Z0-9.)) finishes the optional statement. So, if at least one space is provided, at least one optional character, number or . can also be added.
For instance, ab, ab , ab .s, and ab .asd2 should all be valid inputs.
How do I solve this problem?
The problem with your attempt is that both (?\ and (?a are syntax errors. If you want to create an optional group, you need to write (...)?, not (?...).
(The other issue is that a-zA-Z0-9 in your regex matches literally because it's not part of a character class.)
Besides, \s (to match whitespace) does not exist in POSIX regex.
My suggestion:
^[a-zA-Z]{2}( +[a-zA-Z0-9.]*)?$
That is:
^ # beginning of string
[a-zA-Z]{2} # exactly two letters
(
\ + # one or more spaces
[a-zA-Z0-9.]* # zero or more of: letters, digits, or dot
)? # ... this group is optional
$ # end of string
I am using Oracle 12.2 .I wish to import data pump files. To do that, I wish to create a directory, containing the files and then import. I use the following command to create directory
CREATE DIRECTORY dpump_dir1 AS ‘D:\dumpdir’;
I am getting the error as
SQL Error: ORA-00911: invalid character
00911. 00000 - "invalid character"
*Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
Could anybody tell me what is going wrong?
The quotes being used in the code you provided are not simple straight single quotes; it's slightly easier to see when formatted as code:
CREATE DIRECTORY dpump_dir1 AS ‘D:\dumpdir’;
You can also use your text editor or dump the string to see which chraacters it contains:
select dump(q'[CREATE DIRECTORY dpump_dir1 AS ‘D:\dumpdir’;]', 1016) from dual;
DUMP(Q'[CREATEDIRECTORYDPUMP_DIR1AS‘D:\DUMPDIR’;]',1016)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Typ=96 Len=49 CharacterSet=AL32UTF8: 43,52,45,41,54,45,20,44,49,52,45,43,54,4f,52,59,20,64,70,75,6d,70,5f,64,69,72,31,20,41,53,20,20,e2,80,98,44,3a,5c,64,75,6d,70,64,69,72,e2,80,99,3b
You can see that it's reported at 49 bytes despite being 45 characters long, indicating you have multibyte characters. Before the final semicolon, which is shown as 3b, you have the sequence e2,80,99 which represents the ’ right single quotation mark, and a bit earlier you have the sequence e2,80,98 which represents the ‘ left single quotation mark.
If you use plain quotes it should work:
CREATE DIRECTORY dpump_dir1 AS 'D:\dumpdir';
Presumably you copied and pasted the text from an editor which helpfully substituted curly quotes.
I have a customer trying to create a table name starting with a number followed by alphabet ( example: 1234-testtable ) and the redshift is throwing
ERROR: syntax error at or near "1234" Position:53
Can't we create a table name starting with number in Amazon Redshift ?
According to the Names and Identifiers documentation, you cannot start your identifier with a digit and it cannot contain a hyphen as only
ASCII letters, digits, underscore characters (_), or dollar signs ($) are valid characters. The complete set rules for Redshift is:
Contain only ASCII letters, digits, underscore characters (_), or dollar signs ($).
Begin with an alphabetic character or underscore character.
Subsequent characters may include letters, digits, underscores, or dollar signs.
Be between 1 and 127 characters in length, not including quotes for delimited identifiers.
Contain no quotation marks and no spaces. Not be a reserved SQL key word.
Thus you could elect for a name like testtable_1234 instead.
I want to write script for internal issue tracking system, integrated with ClearCase, that checks activity name (typed by user) for illegal characters. Unfortunatly, I can't find list of characters, allowed by ClearCase. Does anybody know where to get it?
UPD: I'm looking for a link to a document, that specifies the allowed characters (or says that all characters are allowed).
Regarding mkactivity (the command used for creating activity), there is:
no special limitation for the activity headline
follow the same limitations than any other clearcase object ID name (see below):
cmd-context mkactivity -headline "Create directories" create_directories
Created activity "create_directories".
Set activity "create_directories" in view "webo_integ".
alt text http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m0/topic/com.ibm.rational.clearcase.hlp.doc/cc_main/images/activity.gif
The cleartool man page about arguments in cleartool command is clear:
In object-creation commands, you must compose the object name according to these rules:
It must contain only letters, digits, and the special characters underscore (_), period (.), and hyphen (-).
A hyphen cannot be used as the first character of a name.
It must not be an integer; this restriction includes octal and hexadecimal integer values. However, noninteger names are allowed.
It must not be one of the special names “ . “, “ .. “, or “ ... “.
cleartool supports object names of up to 1024 bytes in length, although Windows imposes a limit of 260 bytes on object names.