Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8695369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:01:01+00:00 2026-06-13T01:01:01+00:00

I’m trying to figure out what datatype I should use in my database to

  • 0

I’m trying to figure out what datatype I should use in my database to store a fixed 8 digits number.

Should I use char(8) even though it accepts other characters and validate on the application side or there is something like number(x) that could make it ?

I’ve got the same dilemma with the phone number column. Should I use char(x) or something would be more appropriate ?

Edit – Answers to your questions:

  1. the first fixed 8 digits column will most likely be used as a primary key. It represents to social security number in my country. No arithmetic will be done on this column. I need to keep all digits (even possible leading zeros). Although, it will probably sorted (since it’ll be a primary key)
  2. For the phone number I was going to store it as a string like this : 12345678901. The question was more about “How can I make sure that this char[] will not accept letters or other characters. Should this validation be made client-side ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:01:02+00:00Added an answer on June 13, 2026 at 1:01 am

    It depends.

    Is it a number? Will you do mathemtical operations on the number? Will you sort it numerically? If yes, then store it as a number. You should also create a constraint to ensure that the number always has 8 digits:

    number_field number(8) check (number_field between 11111111 and 99999999)
    

    If it’s more like a code (like a credit card number, social security number or account number), I think I would use char(8), and a check constraint to ensure that it contains only numbers (a regular expression is a very good use for this). By using a char datatype rather than a varchar you don’t need to make sure that the field contains 8 characters, just that the characters are all digits.

    code_field char(8) check (regexp_like(code_field, '[:digit:]{8}'))
    

    In effect, what you want are domains but Oracle doesn’t have them.

    As to whether to validate client-side or server-side, in my world, I always rely on database constraints to ensure that the data stored in the database is as clean as possible. In my apps, I test for constraint violation to return an appropriate error to the user. Of course, you can do validation client-side too, but why repeat yourself? The only case is when you want to avoid a round trip to the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.