| |

VerySource

 Forgot password?
 Register
Search
View: 786|Reply: 5

Ask: Why the SQL statement does not take effect

[Copy link]

3

Threads

10

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-24 10:00:01
| Show all posts |Read mode
create table zz (
A varchar (8) not null,
B varchar (4) not null,
c decimal (13,6) null,
d datetime null,
constraint PK_zz primary key (A, B)
)
Why is the length of c decimal still 9
     c decimal (13,6) null, no effect thank you
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-5-7 23:15:01
| Show all posts
--9 is the number of bytes occupied by stored data
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-5-7 23:45:01
| Show all posts
decimal and numeric
A numeric data type with fixed-point precision and decimal places.

decimal [(p [, s])] and numeric [(p [, s])]

Fixed-point precision and decimal places. With maximum precision, valid values ​​range from-10 ^ 38 +1 to 10 ^ 38-1. SQL-92 synonyms for decimal are dec and dec (p, s).

p (accuracy)

Specify the maximum number of decimal digits that can be stored to the left and right of the decimal point. The precision must be a value from 1 to the maximum precision. The maximum accuracy is 38.

s (number of decimal places)

Specify the maximum number of decimal digits that can be stored to the right of the decimal point. The number of decimal places must be a value from 0 to p. The default number of decimal places is 0, so 0 <= s <= p. The maximum storage size varies based on accuracy.

Accuracy Stored bytes
1-9 5
10-19 9
20-28 13
29-38 17
Reply

Use magic Report

0

Threads

49

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-5-8 09:00:01
| Show all posts
c decimal (13,6)

When you specify the length in this way, the length of c must be 9 Ah!
Length depends on accuracy!

c decimal (9,6) this length is 5

But I do n’t know if I can meet the needs of the landlord
Reply

Use magic Report

0

Threads

28

Posts

25.00

Credits

Newbie

Rank: 1

Credits
25.00

 China

Post time: 2020-5-8 13:45:01
| Show all posts
decimal [(p [, s])] and numeric [(p [, s])]

Fixed precision and decimal places. With maximum precision, valid values ​​range from-10 ^ 38 +1 to 10 ^ 38-1. SQL-92 synonyms for decimal are dec and dec (p, s). numeric is functionally equivalent to decimal.

p (accuracy)

Up to the total number of decimal digits that can be stored, including the digits to the left and right of the decimal point. The precision must be a value from 1 to a maximum precision of 38. The default precision is 18.

s (number of decimal places)

The maximum number of decimal digits that can be stored to the right of the decimal point. The number of decimal places must be a value from 0 to p. You can specify the number of decimal places only after specifying the precision. The default number of decimal places is 0; therefore, 0 <= s <= p. The maximum storage size varies based on accuracy.


Accuracy Stored bytes
1-9
 5
 
10-19
 9
 
20-28
 13
 
29-38
 17
Reply

Use magic Report

3

Threads

10

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-5-10 08:45:01
| Show all posts
Thank you everybody thank you understand thank you
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list