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 8952765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:56:49+00:00 2026-06-15T13:56:49+00:00

I have learnt that VARCHAR occupies the only memory which is required unlike CHAR

  • 0

I have learnt that VARCHAR occupies the only memory which is required unlike CHAR which always occupy same amount of memory whether needed or not.

My question: Suppose I have a field VARCHAR(50), I know that if it needs to store 30 characters, it will only occupy 30 bytes and no more than that(assuming 1 char takes one byte). So why should I even mention 50 or 30 or any upper limit, since it will only take the memory which is required.

UPDATE: Why do I have to mention the upper limit since there will be no useless memory occupied?

  • 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-15T13:56:50+00:00Added an answer on June 15, 2026 at 1:56 pm

    UPDATE: Why do I have to mention the upper limit since there will be no useless memory occupied?

    If you are sanitizing your inputs with something like final_value = left(provided_value, 30) then it’s a non-issue for your database. You can set it to varchar(255) if you like.

    The idea of putting the max limit is to ensure you don’t mistakenly send more chars than what you actually plan for.

    1. Would be a pain in the future for code maintenance to recall the data size limit of every column of every table. You need to do that anyway but by looking at your table definitions as the single source for info about that.

    2. Would a table be written to (insert/update) from only one piece of code in your app or website? If there’s another interface to the database like, say, a REST API listener, if you don’t enter the same values again, you’ll have an issue with non-uniform data – exactly what db’s are able to prevent.

    3. If a coding error (or hack) bypasses your app/website controls for data (size limits, or worse) then at least your db will still be maintaining the data correctly.

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

Sidebar

Related Questions

I have learnt from this post that always use <a> tags or <button> tags
I have learnt that memory for global variables are allocated at program startup whereas
I have learnt that word-length is an ISA feature, which has to be implemented
From an Example unsigned long x = 12345678UL We have always learnt that the
Being a Java developer in an agile development cycle, I have learnt that it
I'm trying to get the hang of inheritance in Java and have learnt that
From another question I have learnt that it is possible in Java to define
In my attempt to learn and understand WebAPI I think I have learnt that
I have registered a domain in iPage.com. But recently i learnt that they are
I have Learnt that Quotes doesn't matter in PHP. But in the following code,

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.