SYBASE: Basic Language Elements (compared with sqlserver)

Source: Internet
Author: User
Tags control characters

Name:

    • Keyword: A string name used for lexical analysis as a constant, mainly used for lexical analysis.
    • Identifier: a string name used for lexical analysis as a variable to identify the object name.
    • Reserved Words. in lexical analysis, a string name cannot be used as an identifier, mainly for compatibility and expansion purposes.

Generally, if a keyword can be referenced by double quotation marks ("") as an identifier, it is called a reserved word. If double quotation marks are not used as an identifier, they are not reserved words.

    • The standard SQL language is case insensitive.
    • The Sybase identifier rules are basically the same as those of sqlserver: the maximum length is 128 characters, case-insensitive, and can be enclosed in double quotation marks or square brackets. When the identifiers comply with general rules, they do not need to be included: the first character is a letter (letters, underscores, @, #, $ ), others are letters, numbers, _, @, #, and $. However, the following characters cannot be used: Double quotation marks, characters smaller than 0x20 (control characters), and double backslash. In other cases, it must be enclosed in square brackets or double quotation marks: the first letter is not a letter and contains spaces. It is a reserved word and contains any character other than the alphabet.
    • The rules for sqlbase identifiers are different from those for sqlserver: sqlserver does not allow $ to be the first letter of a regular identifier; identifiers starting with @ represent global variables; # The identifier at the beginning of a global temporary table

 

Constant:

    • String constant: A Character Sequence enclosed by single or double quotation marks. It is recommended to be enclosed by single quotation marks. The maximum length is 2 GB. It is measured in bytes and characters, the length of a single-byte string is equal to or greater than the length of a Multi-byte string;
    • Nchar String constant: Of course, you can use "n'string'" to guide the nchar string, so that the general length of an English string is equal to the total length of the byte, regardless of the character set.
    • Binary or hexadecimal String constant: starts with "0x" (I do not know whether it is case sensitive? To be verified ?), A string sequence consisting of an even number of [0-9a-f] characters without quotation marks.

The above Sybase and sqlserver are exactly the same !!

Different from sqlserver: sysbase supports escape sequences in four types of strings: two strings can be escaped as a single quotation mark character, and any character can be escaped by a hexadecimal number after the start of "\ x; "\ n" escape line break; "\" escape a backslash character. Sqlserver only supports two escape characters when the quotation marks are single quotes.

 

OPERATOR:

    • Comparison operator: Case sensitivity and trailing blank Processing
    • Logical operators: sqlserver supports many more operators than Sybase, such as some, any, all, In, between, exists, like, and in, but not is. sysbase only supports: and, or, not, is
    • Bitwise OPERATOR:
    • String concatenation operator: In addition to "+", sysbase also supports sql2003 standard "|". sqlserver does not support this operator.

Basically, we can think that the sysbase operator is a subset of the sqlserver operator.

 

Expression:You can calculate the return value of a statement.
Sybase has rich expressions and is much more advanced than sqlserver, which can be:

    • Sybase expression: constants, column names, functions, variables, unary operations, two-element operations, combined operations, subqueries that return only one scalar value, Case expressions, if expressions, and special values (similar to the global system of sqlserver variable or system function)
    • Sqlserver expressions: constants, column names, scalar functions, local variables, unary operations, two-element operations, combination operations, subqueries that only return a scalar value, Case expressions, is [not] null expressions

 

Search criteria:

    • Sybase can only be used in where, having, check, on phrase, and if expressions. It is similar to other SQL Server logical operators and comparison operators, including: binary comparison, {Any | some | all} (multi-row subquery), between, like? Escape? , In, exists, not, And, Or, is [not] {null | true | false | unknown}, display selective Estimation
    • These Search Condition operations are basically the same as those in SQL Server. The like Operation Supports escape, which is a feature of Sybase. It enhances the is test capability.

 

Special Value:The special values of sysbase are similar to the global variables, session variables, and system functions of sqlserver.

 

Variable:

    • Sysbase has three levels of variables: local, connection session, and global. sqlserver has two levels of variables: local and global.
    • You can declare only one local variable for sysbase lifecycle, while SQL server can declare multiple local variables for declare.
    • Sysbase variables can be set through set and select into, while sqlserver can be set through set and select =.

Sybase many global variables are set to be compatible with T-SQL, and many special variables are similar to global variables, or can be understood as the alias of global variables.

 

Note:

    • Sysbase supports four annotator styles: --,/**/, //, and % (must be set)
    • Sqlserver supports two annotation styles :--,/**/

Null Value Problem:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.