Create table: primary key : Create Table « Table Index « SQL / MySQL

Home
SQL / MySQL
1.Aggregate Functions
2.Backup Load
3.Command MySQL
4.Cursor
5.Data Type
6.Database
7.Date Time
8.Engine
9.Event
10.Flow Control
11.FullText Search
12.Function
13.Geometric
14.I18N
15.Insert Delete Update
16.Join
17.Key
18.Math
19.Procedure Function
20.Regular Expression
21.Select Clause
22.String
23.Table Index
24.Transaction
25.Trigger
26.User Permission
27.View
28.Where Clause
29.XML
SQL / MySQL » Table Index » Create Table 
Create table: primary key
   
/*
mysql> Drop table Orders;

mysql> CREATE TABLE Orders
    -> (
    ->    OrderID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
    ->    ModelID SMALLINT UNSIGNED NOT NULL,
    ->    ModelDescrip VARCHAR(40)
    -> );
Query OK, 0 rows affected (0.05 sec)

mysql> Describe Orders;
+--------------+----------------------+------+-----+---------+-------+
| Field        | Type                 | Null | Key | Default | Extra |
+--------------+----------------------+------+-----+---------+-------+
| OrderID      | smallint(5) unsigned |      | PRI | 0       |       |
| ModelID      | smallint(5) unsigned |      |     | 0       |       |
| ModelDescrip | varchar(40)          | YES  |     | NULL    |       |
+--------------+----------------------+------+-----+---------+-------+
3 rows in set (0.01 sec)


*/
Drop table Orders;

CREATE TABLE Orders
(
   OrderID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
   ModelID SMALLINT UNSIGNED NOT NULL,
   ModelDescrip VARCHAR(40)
);

Describe Orders;
           
         
    
    
  
Related examples in the same category
1.Create Simple Tables
2.Create table: default value for column
3.Create table: small int and unsigned int
4.Create table: smallint, decimal and float
5.Create table: char, varchar
6.Create table: BLOB
7.Create table: char set and language
8.Create table: ENUM and set
9.Create table: YEAR and TIMESTAMP
10.Create table: null and not null
11.Create table: not null and default value
12.Create table: default int value
13.Create table: primary key 2
14.Create table: two columns for primary key
15.Create table: auto increment primary key
16.Create table: REFERENCES
17.Create table: foreign key
18.Create table: engine type INNODB
19.Set average row length and max, min rows
20.Syntax for Creating Tables (CREATE TABLE)
21.Create an empty table, use a WHERE clause that is always false
22.To produce a summary that includes all hours of the day, create a reference table that lists each hour
23.Creates table-level privileges.
24.Create a copy of the product table:
25.Create a table called cust_names using the table definitions and data from the product table.
26.CREATE TABLE IF NOT EXISTS
27.CREATE TABLE TEAMS_COPY1 LIKE TEAMS
28.Creating Copies of a Table
29.Creating a New Table by Copying
30.Creating a Table
31.Add an IF NOT EXISTS clause to the statement:
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.