Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

Difference between create table and alter table – upgrade process.

$
0
0

Hi

Let use this example to present my issue.

I develop some application that from time to time is released to the customers. This app has database and in this db I have table Users with two columns: Id and Name.

There might be situation when I will have to change somehow this table e.g. add new column SecondName. In such case the app in old customers will have to be upgraded to new version without losing any data. So I will have to deliver sql script that adds this column to the Users table.

I might have also some new customers that did not have my app before so for these customers sql script that creates whole table with all 3 columns could be used.

I would like to avoid maintain two “streams” for sql scripts one for upgrade and one for clean installation and have only upgrade scripts. In such case for new customers I would create table with two columns (Id and Name) and next run sql script with alter table that adds the new column “SecondName”.

The question is if there is any difference e.g. in performance when I create table with only “CREATE TABLE” statement and when I create table  using CREATE TABLE only for Id and Name and ALTER TABLE that adds additional column. Maybe the table in scenario with CREATE and ALTER is slower even if ALTER is executed when the table is empty because it will be more defragmented?

Regards


kicaj


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>