Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Data definition language
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====CREATE TABLE statement==== A commonly used ''CREATE'' command is the ''CREATE TABLE'' command. The typical usage is: CREATE TABLE ''[table name]'' ( ''[column definitions]'' ) ''[table parameters]'' The column definitions are: *A comma-separated list consisting of any of the following *Column definition: ''[column name]'' ''[data type]'' ''{NULL | NOT NULL}'' ''{column options}'' *[[Primary key]] definition: ''PRIMARY KEY'' ( ''[comma separated column list]'' ) *Constraints: ''{CONSTRAINT}'' ''[constraint definition]'' *[[relational database system|RDBMS]] specific functionality An example statement to create a table named ''employees'' with a few columns is: <syntaxhighlight lang="sql"> CREATE TABLE employees ( id INTEGER PRIMARY KEY, first_name VARCHAR(50) not null, last_name VARCHAR(75) not null, mid_name VARCHAR(50) not null, dateofbirth DATE not null ); </syntaxhighlight> Some forms of ''CREATE TABLE DDL'' may incorporate DML ([[data manipulation language]])-like constructs, such as the ''CREATE TABLE AS SELECT'' (CTaS) syntax of SQL.<ref> {{cite book | last = Allen | first = Grant | others = Mike Owens | title = The Definitive Guide to SQLite | url = https://books.google.com/books?id=WLinoJaOUCwC | access-date = 2012-10-02 | edition = 2 | series = Apresspod | year = 2010 | publisher = Apress | isbn = 9781430232254 | pages = 90β91 | quote = The ''create table'' statement has a special syntax for creating tables from ''select'' statements. [...]: [...] ''create table foods2 as select * from foods;'' [...] Many other databases refer to this approach as ''CTaS'', which stands for Create Table as Select, and that phrase is not uncommon among SQLite users. }} </ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)