Page 171 - IT-802_class_12
P. 171

Syntax:

            iNSERT iNTO Table_Name (column_name1, column_name2, column_ name3 ....)
            VALUES (‘VALUE1’, ‘VALUE2’, ‘VALUE3’);
            Example:

            iNSERT iNTO EmpLOyEE_DETAiLS (Emp_NAmE, Emp_DEpARTmENT, Emp_DESiGNATiON,
            DATE_OF_BiRTH, ADDRESS)
            VALUES (‘SOmNATH_pATRA’, ‘ACADEmiCS’, ‘COmpUTER TEACHER’, ‘2005-05-05’, ‘RANCHi’);

            1.4.7 Select

            This command is used to display all the results of table.
            Syntax:

            SELECT * FROm Table_Name;
            Example

            SELECT * FROm EmpLOyEE_DETAiLS;
            Output:
            +---------------+----------------+------------------+---------------+---------+
            | Emp_NAmE      | Emp_DEpARTmENT | Emp_DESiGNATiON  | DATE_OF_BiRTH | ADDRESS |
            +---------------+----------------+------------------+---------------+---------+
            | SOmNATH_pATRA | ACADEmiCS      | COmpUTER TEACHER | 2005-05-05    | RANCHi  |
            +---------------+----------------+------------------+---------------+---------+
            Sometimes only a portion of the string needs to match. String pattern matching is what this is known as. For indicating
            varying character counts, the ‘LIKE’ keyword can be used in conjunction with two additional reserved characters:
            % (for percent) and _(for underscore). A single character is replaced by _, whereas zero or more random characters
            are replaced by %.
            For example, the following command is used to retrieve the records of all employees whose names begin with the
            letter “N”:

            SELECT * FROm EmpLOyEE_DETAiLS
            WHERE Emp_NAmE LiKE “N%”;
              1.5 DataBase constRaints

            For smooth functioning, SQL allows us to impose numerous constraints on a table at the time of its creation. Let us learn
            about some constraints.
            1.5.1 NOT NULL Constraints

            The NOT NULL constraint enforces that a column in a table may not allow NULL values, which means that the column
            must contain a value. For example, if we want the Roll_No column of the STUDENT table not to be NULL, the NOT NULL
            constraint can be used.

            CREATE TABLE STUDENT
            (
            Roll_No iNTEGER NOT NULL,
            Name VARCHAR(30),

            Gender CHAR(1),
            Date_of_Birth DATE,


                                                                                 Database Concepts—RDBMS Tool   169
   166   167   168   169   170   171   172   173   174   175   176