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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:01:32+00:00 2026-06-01T18:01:32+00:00

I have at least 65 VARCHAR columns in Table A that I would have

  • 0

I have at least 65 VARCHAR columns in Table A that I would have to resize from X bytes to X char. I was hoping to find a simpler way than issue ALTER TABLE A MODIFY.. command 65 times.

Can anyone please help me out how I can do this is a faster way?

  • 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-01T18:01:33+00:00Added an answer on June 1, 2026 at 6:01 pm

    You can write a bit of dynamic SQL. Assuming that the table is in the current schema

    DECLARE
      l_sql_stmt VARCHAR2(1000);
    BEGIN
      FOR t IN (SELECT * FROM user_tab_cols WHERE table_name = 'A')
      LOOP
        l_sql_stmt := 'ALTER TABLE ' || t.table_name || ' MODIFY (' || 
                         t.column_name || ' varchar2(' || t.char_length || ' char))';
        EXECUTE IMMEDIATE l_sql_stmt;
      END LOOP;
    END;
    

    Which you can see working below

    SQL> ed
    Wrote file afiedt.buf
    
      1  create table foo(
      2    col1 varchar2(10 byte),
      3    col2 varchar2(20 byte)
      4* )
    SQL> /
    
    Table created.
    
    DECLARE
      l_sql_stmt VARCHAR2(1000);
    BEGIN
      FOR t IN (SELECT * FROM user_tab_cols WHERE table_name = 'FOO')
      LOOP
        l_sql_stmt := 'ALTER TABLE foo MODIFY (' || 
                         t.column_name || ' varchar2(' || t.char_length || ' char))';
        EXECUTE IMMEDIATE l_sql_stmt;
      END LOOP;
    END;
    
    
    SQL> desc foo;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     COL1                                               VARCHAR2(10 CHAR)
     COL2                                               VARCHAR2(20 CHAR)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that contains the next columns: ip(varchar 255), index(bigint 20), time(timestamp)
I need to find all patrons that have at least 1 circulation record. Here's
I have a table that has columns YEAR and MONTH, which are varchars, which
If i have a table that looks like this: ID int Name varchar City1
I have a winforms datagridview that seems to always have at least one row
I have spent at least 2 weeks now trying to find out how to
I have a project that is supposed to run on different (at least 2)
I have an application that I'm trying to build with at least a nominally
I have a table Car in my db, one of the columns is purchaseDate.
I have a database with VARCHAR column url . I would like to fetch

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.