Create Database and Tables

Results 1 to 2 of 2

Thread: Create Database and Tables

  1. #1
    Join Date
    Dec 1969

    Default Create Database and Tables

    I read an article which says you can create database and tables with following code.<BR><BR>CREATE DATABASE database_name;<BR>CREATE TABLE table_name <BR>(<BR>field1 varchar,<BR>field2 varchar,<BR>field3 varchar,<BR>);<BR><BR>How I get this to work with ASP please?

  2. #2
    SPG Guest

    Default Create Table Syntax

    1) There is no official "Create Database" syntax. SQL Server 7 has some nifty features to it -- especially for COM programmers -- but I&#039ve not actually gotten around to using them. Poke around the serious SQL sites (and MSDN) for more info.<BR><BR>2) Create Table syntax (SQL-92) is as follows:<BR><BR>create table &#060;table name&#062; (table element list)<BR><BR>Not very useful, right? That&#039s because you can do far too much with a table to describe in a nice concise specification. Check out this example and see if it helps...<BR><BR>create table foo (<BR> objID integer identity(1, 1),<BR> sName varChar(80) not null,<BR> iRef integer not null,<BR> iClass integer default 10,<BR> iFoo integer unique,<BR> dMod datetime not null,<BR> sComment varChar(1000) null,<BR> primary key (objID),<BR> foreign key iRef references bar(objID)<BR> )<BR><BR>That gives you a table with an autonumbering primary key and a wide variety of constraints across it. Furthermore it references out to another table with a foreign key. <BR><BR>Hope it helps.

Posting Permissions

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