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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:50:49+00:00 2026-05-26T12:50:49+00:00

I have a table (it was imported from Excel) that has a wide variety

  • 0

I have a table (it was imported from Excel) that has a wide variety of automatically identified/assigned types (int, float, decimal, etc). There are about 160 columns…and i want to standardize them. I know that to change the field type i use ALTER TABLE and the CHANGE command…but you have to specify the column name…and i really don’t want to have to do this individually for every column. I tried something like this:

ALTER TABLE `Table_Name` CHANGE * * DECIMAL( 7, 4 ) NULL DEFAULT NULL 

but that did not work. To make matters slightly more complicated…there is actually one field which is the primary key StateName that is not numeric (the values are like TX,VA,FL,NY)…and do i need to leave it alone.

In short, i am looking for something like:

ALTER TABLE `Table_Name` CHANGE * * DECIMAL( 7, 4 ) NULL DEFAULT NULL EXCEPT WHERE Column='StateName'   

I just made up that syntax…i know it is nowhere close.

Can this be done?

  • 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-05-26T12:50:49+00:00Added an answer on May 26, 2026 at 12:50 pm

    So…based on the “answer” from OMG Ponies and assuming that there really is not a way to do this within MySQL…i wrote the following PHP script which accomplished the complete job in less than 1 second…

    $sql = "SHOW COLUMNS FROM `Table_Name`";
    $result = @mysql_query($sql, $db);
    while($row = mysql_fetch_array($result)){
        $ColumnName = $row[0];
        if($ColumnName!='StateName'){
            $UpdateSql = "ALTER TABLE `Table_Name` CHANGE `$ColumnName` `$ColumnName` DECIMAL( 7, 4 ) NULL DEFAULT NULL ";
            @mysql_query($UpdateSql, $db);
        }
    }
    

    Hopefully it helps someone else someday.

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

Sidebar

Related Questions

I have a large table I imported from an Excel spreadsheet. For five of
I have a MySQL table that I have imported from a CSV file. In
I have an Excel file (which has data imported from Oracle 10G Database) one
I have data imported from an excel sheet into a table in db. Now
I have a single entry output from a paradox table which is imported into
I have a table that was imported as all UPPER CASE and I would
I have a table with 600+ columns imported from a CSV file with special
I am trying to pull data from a table I have imported into my
I have to migrate database from mysql to ms sql server 2005.I imported table
So imagine 2 big mysql tables imported from Excel. Table1 has the field SNameID,

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.