ASP
  Home arrow ASP arrow Creating And Altering Tables In Microsoft ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Creating And Altering Tables In Microsoft SQL SERVER 2000
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 50
    2003-10-06

    Table of Contents:
  • Creating And Altering Tables In Microsoft SQL SERVER 2000
  • Bit By Bit
  • Creating A Table

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating And Altering Tables In Microsoft SQL SERVER 2000


    (Page 1 of 3 )

    We have already covered some hardcore details about RDBMS, and how it evolved in the previous tutorial. We also dealt briefly about designing logical databases and how to build database connected systems. We concentrated more on SQL Server 2000 and .NET technology; it's new features and extended support. In addition enumerated in detail about the various Database Objects in SQL Server 2000, and discussed at length about the first database object-the database itself.

    At this point, you have a solid foundation on how to create our own database using the complex CREATE DATABASE syntax, which will come in handy during real time application development, or for verifying and editing codes. In today’s tutorial we will fine-tune our skills on creating a database and discuss on the concepts of adding tables to our database. The easiest way to create a database is to use SQL Server Enterprise Manager, which provides a graphical front end to Transact-SQL commands and stored procedures that actually create the database and set its properties. Open Enterprise Manager’s, Database Properties dialog box, which represents the Transact-SQL CREATE DATABASE command for creating a new user database. Only someone with the sysadmin role or a user who's been granted CREATE DATABASE permission by a DBA can issue the CREATE DATABASE command.

    When you create a new user database, SQL Server copies the model database, which—as you learned earlier—is simply a template database. A new user database must be 1 MB or greater in size, and the primary data file size must be at least as large as the primary data file of the model database. Kindly remember, if Enterprise Manager is used to create a database called newdb, the default logical and physical names will be different than if you use the CREATE DATABASE command. Enterprise Manager will give the data file the logical name of newdb_Data (instead of just newdb), and the physical file will have the name newdb_data.mdf.

    In this section, we will be studying the syntax to create our own tables. We will also take a look at how to make use of the Enterprise Manager to help us with this, only after we know how to do it ourselves. For it is always better to understand the basics of how it works. {mospagebreak title=Create Table Made Easy} The first part of creating a table is pretty much the same as creating any object. Remember the syntax we already learned, well here it is again
    
    Create <object type><object name>
    
    Since a table is what we want we can be more specific:
    
    Create table customer
    
    With Create Database, we could have stopped with just these first three key words, and SQL Server would have built a database based on the guidelines established in the model database. With CREATE TABLE syntax however there is no “model” table (unlike “model” database) set up in the Server to mimic it, we have to provide all the specifications in the form of columns, data types and special operator.
    
    Create Table [database_name.[owner].]table_name
    (<Column name> <data type>
    [ [DEFAULT <constant expression>]
    |[IDENTITY [ (seed, increment) [ NOT FOR REPLICATION]]]
    [ROWGUIDCOL]
    [COLLATE <collation name>]
    [Null| NOT NULL]
    [<Column constraints>]
    [column_name as computed_column_expression]
    [<Table constarints>]
    [,…n]
    )
    [ON {<filegroup>|DEFAULT}]
    [TEXTIMAGE_ON {<filegroup >|DEFAULT]
    
    Now that’s a handful, believe me it still has sections taken out of it for simplicity sake! Don’t worry; let’s look at it part by part starting with the second line.

    More ASP Articles
    More By Gayathri Gokul


     

    ASP ARTICLES

    - Using MySQL with ASP
    - ADO for the Beginner
    - ADO.NET 101: Data Rendering with a DataGrid ...
    - Introducing SoftArtisans OfficeWriter 3.0 En...
    - Getting Remote Files With ASP
    - The Real Basics of Functions in ASP
    - Enhancing Readability with ASP
    - Mimicking PHP's String Formatting Functions
    - Windows Server Hacks 12, 77, and 98
    - How to Sort a Multi-Dimensional Array
    - Developing an Information Management Tool wi...
    - What are Active Server Pages?
    - Getting Remote Pages with ASP
    - FTP’ing Files with ASP
    - Apply Single-Sign-On to Your Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT