Skip to main content

SQL Set Operators

SQL Set Operators   Traditional Set Operators: Union Compatibility:     Requirement for the traditional set operators.    Strong requirement.                         - Same number of columns.                         - Each corresponding column is compatible.                         - Positional correspondence.     Apply to similar tables by removing columns first. SQL UNION Example:           Example 1: Retrieve basic data about all university people.                     SELECT FacNo AS PerNo, FacFirstName                                      ...

DDL | Data Definition Language

DDL | Data Definition Language

        DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema.

            •CREATE – is used to create the database or its objects (like table, index, function, views, store procedure and triggers).

            •DROP – is used to delete objects from the database.

            •ALTER – is used to alter the structure of the database.

            •TRUNCATE – is used to remove all records from a table, including all spaces allocated for the records are removed.

            •COMMENT – is used to add comments to the data dictionary.

            •RENAME – is used to rename an object existing in the database. 

"CREATE"

        create table mytab( c1 int, c2 varchar(255))


        create table mytab1( C1 int NOT NULL, c2 varchar(255))


        create table mytab2( C1 int NOT NULL UNIQUE, c2 varchar(255))


        create table mytab3( C1 int NOT NULL PRIMARY Key, c2 varchar(255))


        create table mytab4( C1 int , c2 varchar(255), PRIMARY KEY (c1,c2))


        create table mytab5( c1 int, c2 int, c3 varchar(200), PRIMARY KEY (c1,c3), FOREIGN KEY (c2) REFERENCES mytab3(c1))


        create table mytab6( c1 int PRIMARY KEY, c2 varchar(255), c3 varchar(50) DEFAULT 'KARACHI');


        create table mytab7( c1 int PRIMARY KEY, c2 varchar(255), c3 int CHECK (c3>=10) );


create table mytab8( c1 int PRIMARY KEY, c2 varchar(255), c3 int, CHECK (c1>15 AND c3>=10) );




"DROP"


        drop table mytab8 truncate table mytab1


"ALTER"


        ALTER TABLE - ADD Column

        ALTER TABLE mytab1

        ADD c5 int

        ALTER TABLE mytab1

        ADD c6 int

        ADD c7 int


             DROP Columns

            ALTER TABLE mytab1

            DROP column c6

            ALTER TABLE mytab1

            DROP (c5,c2)

            ALTER TABLE mytab1

            modify c7 varchar(100)




Our Official Website : Web Conquerors (https://www.webconquerors.com/) 

Want to get digital services? Contact US

Want to know about our services? Our Services


Comments

Popular posts from this blog

SQL Set Operators

SQL Set Operators   Traditional Set Operators: Union Compatibility:     Requirement for the traditional set operators.    Strong requirement.                         - Same number of columns.                         - Each corresponding column is compatible.                         - Positional correspondence.     Apply to similar tables by removing columns first. SQL UNION Example:           Example 1: Retrieve basic data about all university people.                     SELECT FacNo AS PerNo, FacFirstName                                      ...
  d. Insert a new row in the Location table related to the Facility row in modification problem (c). The new row should have “Door” for the location name. Query Formulation + Result Snapshot Our Official Website :  Web Conquerors  (https://www.webconquerors.com/)  Want to get digital services?  Contact US Want to know about our services?  Our Services

Correction For ERD

 d. For each consistency error in Figure 1, you should identify the consistency rule violated and suggest possible resolutions of the error. The ERD has generic names to help will concentrate on finding diagram errors rather than focusing on the meaning of the diagram. Answer:                Entity6 is violation of the Primary key rule. As there are 3 attributes from within Entity6 that are marked as primary key. Entity6 also violates the Identifying relationship rule, as there is no foreign key in the Entity6 table to identify the item from Entity7. Since this a weak entity type, the cardinality must be 1:1, which it is not. Entity2 is a violation of the Identifying relationship rule due to it not being a weak entity type when there is an identifying relationship. Our Official Website :  Web Conquerors  (https://www.webconquerors.com/)  Want to get digital services?  Contact US Want to know about our services?  ...