Sybase DDL Statements

Sybase DDL Statements: Data Definition Language(DDL) commands are used to define the structure of the table or databases. Data Definition Language commands are:
CREATE
ALTER
DROP
TRUNCATE

CREATE Statement: Create command is used to create database and database objects such as table, view, stored procedure, triggers, …. etc.

Syntax:
CREATE DATABASE db_name
or
CREATE TABLE table_name(columnname1 datatype, columnname2 datatype, ………..)

Example:

create table pinnapa(tech_name varchar(30), author_name varchar(50))

ALTER Statement: Alter statement is used to change the structure of database or its objects. We can change size of database or constraints on a table or we can add new column to the table.

Example:

alter database pinnapa
on pinnapadata=20 log on pinnapalog=10
go

alter table pinnapa add(published_date date)
go

TRUNCATE Statement: Truncate is used to delete the all the rows from a table. Truncate is faster than delete statement.

Example:

truncate table accounts
go

DROP statement: Drop is used to drop the databases and its objects. Drop is also used to drop columns, constraints and indexes on the table.

Example:

DROP table accounts
go

Powered by k2schools