Re: Regarding varchar



Prateek Jain wrote:
Hello everybody,
I have one table in which varchar is declared as
varchar(100,1)
whats the significance of 1 in the above varchar().
any idea.

This is explained in the Guide to SQL Reference and the Guide to SQL Syntax even. Q&D you declare a VARCHAR (variable length character) column as (max, reserved) - the engine allocates each new row with at least 'reserved' + 1 bytes (to record the column's actual length) on the row's data page(s) or the actual number of bytes in the column's data + 1 byte (if the data is longer than 'reserved') up to 'max' bytes + 1. Older OnLine documentation seemed to indicate that when a VARCHAR column was expanded to accomodate a longer value it was expanded by at least 'reserved' bytes perhaps to minimize row relocations for variable length rows that grow over time. It's not clear in the docs if this was true then or if it was that it's still true in IDS.

Art S. Kagel
.



Relevant Pages

  • Cursor Not Running Correctly.. Need Help/Suggestions...
    ... DECLARE @NewOrderID INT ... DECLARE @CompanyName VARCHAR ... INNER JOIN Orders ... DECLARE @SubTotal MONEY ...
    (microsoft.public.sqlserver.programming)
  • Re: Regarding varchar
    ... Q&D you declare a VARCHAR column as (max, ... seemed to indicate that when a VARCHAR column was expanded to accomodate a longer value it was expanded by at least 'reserved' bytes perhaps to minimize row relocations for variable length rows that grow over time. ...
    (comp.databases.informix)
  • Re: No results found for my search!
    ... declare @search_key1 as varchar ... For all the search keys which are: ... they ALL are specifications for item_id 2. ...
    (comp.databases.ms-sqlserver)
  • Re: Concatenating and copying columns data
    ... DECLARE @PROC_PROJID VARCHAR ... SELECT COUNTINTO fldCount FROM ALL_TAB_COLUMNS WHERE ...
    (comp.databases.oracle.server)
  • Queries with cursors cant be executed back to back
    ... Since the cursors have different names and have ... DECLARE @SiteName varchar ... DECLARE @Reporting_ID int ...
    (microsoft.public.sqlserver.dts)