Tutorial Addendum on SQL - Data Types and Literals
| |
Example 2 - HexStringLiterals.sql:
-- HexStringLiterals.sql
-- Absorb (c) 1999 by Dr. Yang
--
SELECT x 41424344 AS LINE_1;
SELECT x 31323334 AS LINE_2;
SELECT x 31323334 + 0 AS LINE_3;
SELECT x 01 + 0 AS LINE_4;
SELECT x 0001 + 0 AS LINE_5;
SELECT x ff + 0 AS LINE_6;
SELECT x ffffffff + 0 AS LINE_7;
SELECT x ffffffffffffffff + 0 AS LINE_8;
Output
LINE_1
ABCD
LINE_2
1234
LINE_3
825373492
LINE_4
1
LINE_5
1
LINE_6
255
LINE_7
4294967295
LINE_8
-1
Notes:
- Line 1 and 2 acquaint us that hex cord literals are evaluated into appearance strings
in a cord expression.
- Line 3, 4, 5, 6 and 7 acquaint us that hex cord literals are evaluated into numbers
in numeric expression.
- Line 8 tells us that the bifold representation of an accumulation is 8 bytes.
The amount of the first bit on the larboard marks the accumulation to be negative.
Example 3 - NumericLiterals.sql:
-- NumericLiterals.sql
-- Absorb (c) 1999 by Dr. Yang
--
SELECT 1 AS LINE_1;
SELECT -2 AS LINE_2;
SELECT 3.3 AS LINE_3;
SELECT -4.4e+4 AS LINE_4;
SELECT 12345678901234567890 AS LINE_5;
SELECT 0.12345678901234567890 AS LINE_6;
SELECT 1234567890.1234567890 AS LINE_7;
SELECT 12345678901234567890.1234567890 AS LINE_8;
SELECT 1234567890.1234567890e+10 AS LINE_9;
SELECT 0.0000000000000000000012345678901234567890 AS LINE_10;
SELECT 1.0e+1234567890 AS LINE_11;
Output:
LINE_1
1
LINE_2
-2
LINE_3
3.3
LINE_4
-44000
LINE_5
123456789012345680000000000000
LINE_6
0.12345678901234568000
LINE_7
1234567890.1234567000
LINE_8
12345678901234567000.0000000000
LINE_9
1.2345678901235e+019
LINE_10
1.2345678901235e-021
LINE_11
1.#INF
A amount of absorbing addendum here:
- Line 4 tells us that an almost numeric accurate could be evaluated into an integer.
- Line 5, 6, 7 and 8 acquaint us that exact numeric literals are evaluated upto about 17 digits.
- Line 9 tells us that an almost numeric accurate is evaluated upto about 15 digits.
- Line 10 tells us that an exact numeric accurate could be adapted into an almost numeric value.
- Line 11 tells us that if the centralized accumulator amount absolute is reached, an almost numeric
literal is evaluated to "1.#INF".
|
select, numeric, evaluated, literals, tells, literal, approximate, value, integer, string, notes, , numeric literal, approximate numeric, evaluated into, literals are, approximate numeric literal, evaluated upto about, numeric literal could, sql data types, hex string literals, |
Also see ...
This affiliate describes:What are the types and levels of locks?How table akin locks plan in MySQL?How row akin locks plan in MySQL?br
We all understand that assorted locks in assorted sessions could couldcause deadlocks. Let s see if we can make a deadlock in MySQL amid two sessions: mysql Alert ;DROP TABLE IF EXISTS User;
This affiliate describes:What s in MySQL?How to use the SQL applicant apparatus mysql.How to dump data into files.How to amount data from fil
To assassinate the statements in hello.sql, you can use the "source" commandinside mysql: mysqlinmysql host localhost test......mysql antecedent hello.sqlQuery OK, 0 rows affli
This affiliate describes:Expressions.Arithmetic operations.Predicate operations.Date and time operations.Operation examp
Predicate OperationsPredicate operations are operations that can be evaluated to accord a action of true or false:1. "Comparison" Predicates: Compares
Operation ExamplesExample 1 NumericOps.sql NumericOps.sql Absorb (c) 1999 by Dr. Yang SELECT 1 + 2 AS LINE_1;SELECT 2 / 3 AS LINE_2;
This affiliate describes:What is a stored procedure?How to make a stored procedure.How to canyon data through parameters.
Here is a simple analysis on stored action the MySQL applicant tool: mysql USE test; mysql DELIMITER / ;mysql Make Action Msg() BEGIN Baddest CURRENT_TIME() AS Time;br
This affiliate describes:Local variables in stored procedures.Execution breeze ascendancy statements.Cursor accompanying statements.br