Does ' and " make a big difference in SQL? [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm watching a video on SQL and the guy is making a distinction between ' and ". In Python and R, I tend to use ' and " interchangeably while technically there is a minor difference or in certain situations one needs to be used. However for the most part in Python/R it doesn't matter.
Is this the same in SQL and the guy is just over analyzing or is there actually a big difference between ' and "? Unfortunately, I don't actually work with SQL so I can't really learn from experience - just have to watch vids.
Thanks

Yes, ' and " are very different in SQL.
' is used to indicate strings, such as 'Hello world!'; it is always required.
" is used to indicate identifiers, such as SELECT "name", "age" FROM "people"; it's optional when the name can't be confused with anything, but mandatory if you want unusual names (spaces, upper-case letters) or if you want a name that's reserved (such as "from"); for example SELECT "from", "to" FROM "time slots".
It's generally best to avoid names that have to be quoted, but the option is there if you need it. Many libraries that wrap SQL will habitually quote everything.

Related

Why does visual basic use single quote for comments? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
This seems like a poor choice since the single quote is such a common character and is hard to see when reading over code.
Was there a reason to pick this over a different sequence or less used character?
How doe we arrived to VB.NET:
BASIC (1964) --> QuickBasic (1985) --> Visual Basic (1991) --> VB.NET (2000s)
In Basic, you could insert a comment by beginning your line with REM (for remark)
REM this is a comment
From QuickBasic, the single-quote was introduced, but REM is still valid nowadays
REM this is a comment
' this is another comment
Why is it like this ? We should probably ask Bill gates and Cie about it.
An assumption would be that :
Double quote character was already used to surround strings in BASIC
Single quote character was not used for anything in BASIC
In Bill's mind, a quote is descriptive enough for a comment, in the sense of "to quote someone"

SQL naming convention: Adding data type to column name [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
As a developer, a common mistake that I keep on repeating is assuming the data type of a column. I have read multiple articles regarding SQL column naming convention but have not seen any reference regarding data type as part of the column name - specifically for SQL Server.
E.g. Revenue_f for float, Organization_v for varchar, AccountNumber_i for integer and so on.
This must have been thought of already before but I want to know the reason why it is not being used, or an expert's input regarding the matter; pointing me to the right article/documentations will be greatly appreciated.
That is a horrible naming convention. Consider how awful it would be if you need to change AccountNumber to a character datatype. Do you then go back and rename the column and change every single query everywhere? Or do you leave the suffix in your column name even though it is no longer accurate? If you want to know the datatype of a column the ONLY way is to look at the definition of the table.
Also, a single character really is kind of useless. How do you handle nvarchar vs varchar? And what about the scale?
P.S. Even though I wrote an answer I am voting to close this question because it is primarily opinion based and as such is considered off topic for SO.

regular expression for double consonants [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a problem writing regular expression. I want to write a regular expression that replaces all double consonants with a single consonant.
Please help me to write such a rule in only one line.
Thanks in advance.
Here's a .NET regex that'll find any group of exactly two non-vowels:
[^aeiou]{2}
The following will work for groups longer than 2:
[^aeiou]{2,}
For example, this will match "llst" in "allstar."
Slightly uglier, but will match groups of 2 consonants, case-insensitive:
[QqWwRrTtYyPpSsDdFfGgHhJjKkLlZzXxCcVvBbNnMM]{2}
The following will match two identical non-vowels:
([^aeiou])\1
For example, this would match the "ll" in "all."
Once you have your regex, just use your chosen language's Regex.Replace function.
Since you did not specify the language, I'm going to go ahead and assume Javascript.
This should get you started:
console.log('babble bubble http htttp www'.replace(/([^aeiou\.,\/=?:\d&\s!##$%^*();\\|<>"'_+-])\1{1}/gi, "$1"));
See more here:
http://regexr.com/3ee47

Is it accepted to name a variable like this? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
How acceptable is to name a variable like that:
int Δt = 3;
and not:
int timeDuration = 3;
I love the Delta character.... However it is only acceptable if this becomes a maintainable standard in your code, so that you or your team knows exactly what it is - and you never mix up notation.
It's likely to work, but I absolutely would not recommend it in anything other than personal projects.
Things like varying encoding languages (UTF etc) can affect these kind of unicode characters. Also the fact it's confusing to reliably type and not really hugely semantic.
Languages such as PHP have these guidelines for vars:
Variable names follow the same rules as other labels in PHP. A valid
variable name starts with a letter or underscore, followed by any
number of letters, numbers, or underscores. As a regular expression,
it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'

I keep seeing +--+ in my apache logs, what is it? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am looking at my apache server logs and almost always when someone is scanning the server for vulnerabilities I always see this in their query strings...
+--+
like in the various examples below...
.
.
.
/includes/usercp_register.php?phpbb_root_path=1'+--+?
/includes/profilcp_constants.php?module_root_path=1'+--+?
/includes/functions_user_viewed_posts.php?phpbb_root_path=1'+--+?
/includes/orderSuccess.inc.php?&glob=1&cart_order_id=1&glob[rootDir]=1'+--+
.
.
.
I know they are scanning for popular vulnerabilities but what Im wondering is whats the purpose of +--+?
Im thinking of using that as something I can filter for using fail2ban
In query strings, the plus character is shorthand notation for a space. Remember that spaces are not allowed in URLs, so they must either be percent-encoded (%20) or, only in the query string portion of a URL, represented with a plus. (As a consequence, this means actual pluses must be percent-encoded in the query string but not elsewhere in a URL.)
In this case, the attacker is attempting simple SQL injection. The ' is a quote ('), and the + URL-decodes to a space. So ultimately this happens:
phpbb_root_path=1' --
(The -- is a SQL comment.)
Be careful banning requests with +--+ in the URL; that could be legitimate input -- ie, https://www.google.com/search?q=dash+--+separated