Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register


0
(click on this box to dismiss)

Create and alter table statements

In which different scenarios can we use these statements?

link comment (0) accepted answer
asked 3 years ago
picador_jr
292
1 Answer
1

You use the CREATE TABLE statement to create a table. At the time of creation of the table you can specify the columns of the table, their datatypes and constraints. You can find more info about the usage of the CREATE TABLE statement here. Below is an example of declaring a table which contains information about the Olympic Games.

CREATE TABLE olympic (

host_year INT NOT NULL PRIMARY KEY,

host_nation VARCHAR(40) NOT NULL,

host_city VARCHAR(20) NOT NULL,

opening_date DATE NOT NULL,

closing_date DATE NOT NULL,

mascot VARCHAR(20) ,

slogan VARCHAR(40) ,

introduction VARCHAR(1500)

)

In case your application evolves and you need to modify the database structure you will most probably need to issue an ALTER TABLE statement. You will need to issue an ALTER TABLE statement if you need to add, drop or modify a column, a constraint or an index. Read more about the ALTER TABLE statement here.

link comment (0)
answered 2 years ago
swanotets
263
tagged




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: