I need a column to store credit card numbers and the int size isn't sufficient. However, I keep getting the following message, when trying to set the data type to a bigInt. Any suggestions?
Asked
Active
Viewed 806 times
1
-
2_“I need a column to store credit card numbers”_ – store them as strings; they aren’t really “numbers” anyway. – CBroe Apr 20 '15 at 22:19
-
1Or better yet, don't store them at all. PCI-DSS will eat you alive for that. – Apr 20 '15 at 22:20
-
thanks, but this is just a practice project. No real ssn or creditCard – user3646508 Apr 20 '15 at 22:24
-
3Numbers should be used where arithmetic operations on the data makes sense. You could not add two credit card *numbers*, or divide a phone *number* by 3. As @CBroe said, not everything that is represented with digits is a number. – Majid Fouladpour Apr 20 '15 at 22:28
-
1`BIGINT` or `BIGINT(16)` See https://dev.mysql.com/doc/refman/5.7/en/numeric-type-attributes.html – PM 77-1 Apr 20 '15 at 22:28
-
@Majid Fouladpour, that was a great point to make that I'd never thought of before. – user3646508 Apr 21 '15 at 00:58
-
Answers posted are correct. But FYI you should know that the argument to INT or BIGINT is nearly meaningless. You don't need it. See http://stackoverflow.com/a/3135854/20860 – Bill Karwin Mar 19 '17 at 00:23
2 Answers
3
If you remove the brackets, it will work.
Use BIGINT
instead of BIGINT()

Arthur Tarasov
- 3,517
- 9
- 45
- 57
2
Don't use integers for credit cards. It's not meant to be treated as a numerical data.
Technical reason is that the card number can have a leading zero, which would get truncated.
Use strings.

Ivan Batić
- 476
- 2
- 8