VISUAL QUICKSTART GUIDE SQL Second Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

VISUAL QUICKSTART GUIDE SQL Second Edition [Electronic resources] - نسخه متنی

Chris Fehily

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">








  • Creating a New Table with CREATE TABLE


    This section describes how to create a new table by using a minimal CREATE TABLE statement. Subsequent sections show you how to add column and table constraints to CREATE TABLE.

    To create a new table


      Listing 11.1 creates the sample-database table titles.

      Listing 11.1. Create the sample-database table titles.

      Listing 11.2 creates the sample-database table title_authors.

      Listing 11.2. Create the sample-database table title_authors.

      Tips


      • To see the result of a CREATE TABLE statement, examine the table's structure by using one of the commands described in "Displaying Table Definitions" in Chapter 10.

      • Your DBMS will generate an error if you try to create a table with a name that already exists in the database. To prevent you from overwriting a table accidentally, SQL requires that you destroy a table explicitly with DROP TABLE before creating a new table with the same name; see "Dropping a Table with DROP TABLE" later in this chapter.

      • A newly created table is empty (has zero rows). To populate the table with data, use the INSERT statement; see "Inserting Rows with INSERT" in Chapter 10.

      • Columns allow nulls by default. If you don't want to allow nulls, see "Forbidding Nulls with NOT NULL" later in this chapter.

      • To modify the structure of an existing table, see "Altering a Table with ALTER TABLE" later in this chapter.

      • To create a table by using the structure and data of an existing table, see "Creating a New Table from an Existing One with CREATE TABLE AS" later in this chapter.

      • Microsoft SQL Server doesn't support the data type DATE. To run Listing 11.1, change the data type of the column pubdate to DATETIME.

        MySQL might change the type of a CHAR or VARCHAR column silently when creating a table. VARCHAR columns with a length less than four are changed to CHAR, for example.


    • / 169