SQL Create
Home
SQL Basics:
SQL HOME
SQL Introduction
SQL Select
SQL Where
SQL And & Or
SQL Between
SQL Distinct
SQL Order By
SQL Try It
SQL Insert
SQL Update
SQL Delete
SQL Count
SQL Advanced:
SQL Functions
SQL Group By
SQL Aliases
SQL Join
SQL Create
SQL Alter
SQL Quiz Test
Resources:
SQL Books
SQL Create Database and Table
Create a Database
To create a database:
CREATE DATABASE database_name
Create a Table
To create a table in a database:
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
.......
)
Example
This example demonstrates how you can create a table named
"Person", with four columns. The column names will be
"LastName",
"FirstName", "Address", and
"Age":
CREATE TABLE Person
(
LastName varchar,
FirstName varchar,
Address varchar,
Age number
)
This example demonstrates how you can specify a maximum length for some
columns:
CREATE TABLE Person
(
LastName varchar(30),
FirstName varchar,
Address varchar,
Age number(3)
)
The data type specifies what type of data the column can hold. The table
below contains the most common data types in SQL:
Data Type
Description
char(size)
Holds a fixed length string (can contain letters, numbers, and special
characters). The fixed size is specified in parenthesis
varchar(size)
Holds a variable length string (can contain letters, numbers, and special
characters). The maximum size is specified in parenthesis
number(size)
Holds a number. The maximum number of digits are specified in
parenthesis
number(size, d)
Holds a number. The maximum number of digits are specified in
"size". The maximum number of digits to the right of the decimal are
specified in "d"
date
Holds a date
Delete a Database or Table
To delete a database:
DROP DATABASE database_name
To delete a table:
DROP TABLE table_name
To delete the data in a table without deleting the table:
DELETE TABLE table_name
Jump to : Top Of Page or HOME.
We Help you for free. Please Help us!
Help us correct errors
Help us with spelling and grammar
Tell us what you think
Link to us from your pages
All information in this Web is for training only. We do not make any warranties of its correctness or
its fitness to be used. The risk of using it remains with the user.
Copyright © 1999-2001 by Refsnes Data. All Rights Reserved.
More Tutorials:
HTML XHTML
XML XSL
CSS DTD
WAP WML
JavaScript
DHTML Flash
VBScript ASP
SQL AppML
News:
The Future ofProgramming
Web Security
Browser News
Web Standards
References:
HTML 4.01 Ref
XHTML 1.0 Ref
WML 1.1 Ref
CSS Reference
XSLT Elements
ASCII Reference
Entity Reference
HTML Colors
Color Values
Color Names
WAP Pages
Validation:
HTML XHTML
CSS DTD
XML WML
About W3Scripts
Please link to us
Larger Text?
XML Partners:
Wyszukiwarka
Podobne podstrony:
sql createtablesql createviewsql createusersql functions aspsql groupby aspsql createlanguagesql createaggregatesql alter aspsql orderby aspsql createrulesql createindexsql alias aspsql createtableassql where aspsql quiz aspsql count aspsql select aspsql distinct aspwięcej podobnych podstron