How to Add Long Text Column to Access Table Via Query

25,763

Found the answer shortly after posting the question. Using the query

ALTER TABLE TestTable ADD Description LONGTEXT;

creates a new column of type "Long Text". It should be noted that a character count was not necessary for this type.

Share:
25,763
jaredk
Author by

jaredk

Student programmer just starting out in the professional programming world, with some experience in: C# Java PHP MS Access MySQL Python

Updated on July 23, 2022

Comments

  • jaredk
    jaredk almost 2 years

    I am updating a table in a .mdb format Access database with Access 2013. I want to add a new field, lets say a Description field, to an existing table.

    I can add a text column using the following query

    ALTER TABLE TestTable ADD Description TEXT(255);
    

    Alternatively I could use

    ALTER TABLE TestTable ADD Description varchar(255);
    

    This works fine, and adds a column to TestTable called Description that is limited to 255 characters. If I open the table in Design View, I can see that the type of Description is listed as "Short Text". However, there is an option there to have the field be of type "Long Text" which as far as I can tell doesn't have a character limit. It is easy to manually change the type from the Design View, but I want to know if I can do this via a query.

    I tried increasing the character count in my original query like so

    ALTER TABLE TestTable ADD Description TEXT(300);
    

    But then I recieve the error "Size of field 'Description' is too long."

    What I want to know is can I add the column via a query such that it has a character limit greater than 255? This query is run as part of a macro that is run automatically, so I don't want to have to change it manually. My attempts at searching for a solution via Google have so far come up empty.