PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > alter column increases the size of a table
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alter column increases the size of a table

Réponse
 
LinkBack Outils de la discussion
Vieux 12/09/2008, 18h19   #1
Darlove
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut alter column increases the size of a table

Hi. I change the data type in a column (with data inside) from nvarchar(x) to
varchar(x), which to my mind should entail decreasing the table size, and
what happens is the opposite. The table grows. I issue this:

ALTER TABLE table_name ALTER COLUMN column_name varchar(x);

Please, if anyone knows why the table grows, can you share the knowlegde?
It's very important to me. Is there a way to somehow shrink it or decrease?

Darek
  Réponse avec citation
Vieux 12/09/2008, 18h23   #2
Tom Moreau
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: alter column increases the size of a table

What happens when you rebuild the clustered index?

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau


"Darlove" <Darlove@discussions.microsoft.com> wrote in message
news:55862A5C-ACAE-47B6-8643-0247E587CE3B@microsoft.com...
Hi. I change the data type in a column (with data inside) from nvarchar(x)
to
varchar(x), which to my mind should entail decreasing the table size, and
what happens is the opposite. The table grows. I issue this:

ALTER TABLE table_name ALTER COLUMN column_name varchar(x);

Please, if anyone knows why the table grows, can you share the knowlegde?
It's very important to me. Is there a way to somehow shrink it or decrease?

Darek

  Réponse avec citation
Vieux 12/09/2008, 18h30   #3
Kalen Delaney
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: alter column increases the size of a table

Hi Darek

When changing column widths with ALTER TABLE, SQL Server will not reclaim
the space.
I blogged about it here:
http://sqlblog.com/blogs/kalen_delan...aim-space.aspx

--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
www.SQLTuners.com


"Darlove" <Darlove@discussions.microsoft.com> wrote in message
news:55862A5C-ACAE-47B6-8643-0247E587CE3B@microsoft.com...
> Hi. I change the data type in a column (with data inside) from nvarchar(x)
> to
> varchar(x), which to my mind should entail decreasing the table size, and
> what happens is the opposite. The table grows. I issue this:
>
> ALTER TABLE table_name ALTER COLUMN column_name varchar(x);
>
> Please, if anyone knows why the table grows, can you share the knowlegde?
> It's very important to me. Is there a way to somehow shrink it or
> decrease?
>
> Darek



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h59.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08047 seconds with 11 queries