























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























Data Definition Language A database scheme is defined by set of definitions, which are expressed, by a special set of commands called Data Definition Language (DDL). For example - defining relation schemas, deleting relations, creating indexes and modifying relation schemas. SQL DDL commands are: -
The data manipulation language (DML) handles operations such as entering rows into a table, changing data, deleting rows, and extracting data from rows and tables. It contains commands like ⚫ SELECT ⚫ INSERT ⚫ UPDATE ⚫ DELETE
DATA TYPES IN MYSQL S.No. Data Type Description 1 INT A normal sized signed or unsigned integer ranging from
CREATE TABLE Command - Creating Tables
DESCRIBE COMMAND The describe statement can be used to see the structure of the table as indicated in the Create Command,
| Field | Type | Null | Key |Default | Extra | +--------+------------------+------+-----+---------+---------------+ | rollno | decimal(3,0)| | | | | | name | varchar(15) | | | | | | gender | char(1) | | | | | | marks1 | int | | | | | +--------+------------------+------+-----+---------+---------------+ 4 rows in set (0.00 sec)
CONSTRAINTS
Example – How to Specify constraints? CREATE TABLE Activity ( Regno int Foreign key references student(Regno), . . ); Or CREATE TABLE Activity ( Regno int, . . Foreign key Regno references student (Regno), );
ALTER TABLE Command The ALTER statement can add, remove or change table's column(s) or constraints. Syntax: ALTER TABLE < table_name> ADD/DROP <column_name> [datatype]; Example: ❖ Adding a new column: - mysql> ALTER TABLE student ADD games VARCHAR(5); After this command the games column will be added and a null value will be assigned for all the rows in this column
ALTER TABLE Command continued… ❖ Renaming a Column of a table Syntax ALTER TABLE