the information has to be arranged in the form of tables. The SQL provides a predetermined set of commands to work on databases. Keywords They have a special meaning in SQL. They are understood as instructions.
Commands They are instructions given by the user to the database also known as statements. Clauses They begin with a keyword and consist of keyword and argument. Arguments They are the values given to make the clause complete. 12th Computer Chapter - - .
. DDL Commands CREATE TABLE Command You can create a table by using the CREATE TABLE command. When a table is created, its columns are named, data types and sizes are to be specified. Each table must have at least one column.
The syntax of CREATE TABLE command is : CREATE TABLE <table-name> (<column name><data type>[<size>] (<column name><data type>[<size>]…… ); Now let us use the above syntax to store some information about the students of a class in a database, for this you first need to create table. To create a student table, let us take some information related to students like admission number which we can use it in short form as (admno), name of student (name), gender, age etc. of the student. Let us create a table having the field names Admno, Name, Gender, Age and Place.
The SQL command will be as follows: CREATE TABLE Student (Admno integer, Name char( ), Gender char( ), Age integer, Place char( ), ); The above one is a simple table structure without any restrictions. You can also set constraints to limit the type of data that can go into the fields of the table. Constraints are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the database.
Constraints could be either on a column level or a table level. Constraint is a condition applicable on a field or set of fields. Note Column constraint: Column constraint apply only to individual column. Table constraint : Table constraint apply to a group of one or more columns.