SQL tables by hand

Results 1 to 4 of 4

Thread: SQL tables by hand

  1. #1
    Max W. Guest

    Default SQL tables by hand

    &nbsp;<BR>NOTE: I posted this earlier, but the post seems to have gone missing... <BR><BR>Hi -- <BR><BR>I want to create a database completely from scratch using only SQL commands (for SQL Server). <BR><BR>I want to make a table, with the first column being an identity column that will autonumber itself, and be a primary key. Please tell me the EXACT code to accomplish this, based on the data below. Also, should this column be an Int, a LongInt, or other? <BR><BR>CUST_ID.....this is the identity col <BR>CUST_NAME...varchar(40) <BR>CUST_EMAIL..varchar(40) <BR><BR>Does this make sense? <BR><BR>CREATE TABLE CUSTOMER ( <BR> CUST_ID INTEGER, NOT NULL, IDENTITY(1,1), PRIMARY KEY, <BR> CUST_NAME VARCHAR (40), <BR> CUST_EMAIL VARCHAR (40) <BR> ); <BR><BR>Any help is appreciated... I am sure my syntax is outright wrong or redundant... <BR><BR>Sincerely, <BR><BR>Max Wilkinson

  2. #2
    Garth Guest

    Default RE: SQL tables by hand

    You were close...<BR><BR>CREATE TABLE CUSTOMER ( <BR> CUST_ID INTEGER NOT NULL IDENTITY(1,1) PRIMARY KEY, <BR> CUST_NAME VARCHAR (40), <BR> CUST_EMAIL VARCHAR (40) <BR> ); <BR><BR>The decision to use a smallint or int data type depends on the number of rows the table will hold.<BR><BR>int -&#062; 2,147,483,647<BR>smallint -&#062; 32,767<BR><BR>Garth<BR>www.SQLBook.com

  3. #3
    Max W. Guest

    Default RE: SQL tables by hand

    &nbsp;<BR>Thanks Garth!<BR><BR>I&#039m looking into buying your book, too (just visited our site).<BR><BR>I want to be able to do everything manually, instead of relying on graphical interfaces that make things "easier". I think that if I know the actual code, that will never go out of date (and hence will be a better investment in the time I spend learning).<BR><BR>Sincerley,<BR><BR>Max Wilkinson

  4. #4
    Garth Guest

    Default RE: SQL tables by hand

    Learning how to create database objects with SQL statements is key to advancing your knowledge of the SQL language and SQL Server. Plus, if you want to take the MCP exams you will need to know the SQL approach.<BR><BR>My books won&#039t hit the streets until 1/27, but in the meantime you should download and read Chapter 3. It covers how to create databases, tables and indexes with SQL statements. I also show how it&#039s done via the GUI&#039s so you can see both approaches.<BR><BR>Garth<BR>www.SQLBook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts