C
C
Crash2017-08-17 15:21:56
Python
Crash, 2017-08-17 15:21:56

Which field type to choose for storing mobile phone number (numbers only) in MYSQL DB?

I'm leaning towards BIGINT, because Integer is not suitable here, as I understand it. Is there a better solution? Storage in the format 9xxxxxxxxx, 10 digits including 9-ku, only mobile numbers of the Russian Federation

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2019-04-14
@NeiroNx

Oh, these doters, they are completely lazy ...

import json
data = json.loads("""[{'slot': -1, 'team': 2, 'time': 576.41, 'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'slot': -1, 'team': 2, 'time': 791.491, 'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 129,
  'slot': 6,
  'team': 3,
  'time': 1187.728,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 4,
  'slot': 4,
  'team': 2,
  'time': 1237.115,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 129,
  'slot': 6,
  'team': 3,
  'time': 1366.95,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'slot': -1, 'team': 2, 'time': 1621.088, 'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 130,
  'slot': 7,
  'team': 3,
  'time': 1655.347,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 132,
  'slot': 9,
  'team': 3,
  'time': 1686.872,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 2,
  'slot': 2,
  'team': 2,
  'time': 1751.123,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 4,
  'slot': 4,
  'team': 2,
  'time': 1780.849,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'slot': -1, 'team': 3, 'time': 1927.636, 'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 129,
  'slot': 6,
  'team': 3,
  'time': 2117.449,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'player_slot': 132,
  'slot': 9,
  'team': 3,
  'time': 2156.047,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'key': '512', 'time': 2178.992, 'type': 'CHAT_MESSAGE_BARRACKS_KILL'},
 {'player_slot': 4,
  'slot': 4,
  'team': 2,
  'time': 2326.829,
  'type': 'CHAT_MESSAGE_TOWER_KILL'},
 {'key': '2', 'time': 2333.384, 'type': 'CHAT_MESSAGE_BARRACKS_KILL'}]""".replace("'",'"'))
for i,e in enumerate(data):
  if e['type'] == 'CHAT_MESSAGE_BARRACKS_KILL':
    print(data[i-1])

L
longclaps, 2017-08-17
@Bandicoot

If only to cram - BIGINT, if you would like to have a search, say, by LIKE - then CHAR.
In general, how many phones do you expect to dial? 1000? 1000000? In any case, it will take up quite a bit of space)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question