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                                      ...

DML | Data Manipulation Language

DML | Data Manipulation Language


            DML(Data Manipulation Language) : used for adding (inserting), deleting and modifying (updating) data in a database

                • Insert

                • Update

                • Delete


INSERT INTO:

            INSERT INTO table_name (column1, column2, column3, ...)
            VALUES (value1, value2, value3, ...);

            INSERT INTO table_name
            VALUES (value1, value2, value3, ...);


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

        insert into mytab3 values(01,'Ali')

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


insert into mytab5 (c1)                    insert into mytab5 (c3)
values (10)                                       values ('Ahmed')


insert into mytab5 (c1,c2,c3)
values (111,60,'Ahmed')

                                                        insert into mytab5 (c1,c2,c3)
                                                        values (111,01,'Ahmed')


insert into mytab5 (c1,c3)                insert into mytab5 (c1,c3)                                             
values (09,'Ahmed')                          values (10,'Ahmed')

Re-Run


Update:

            UPDATE table_name
            SET column1 = value1, column2 = value2, ...
            WHERE condition;


update mytab5              update mytab5
set c1=12                      set c1=12
where c1=09                 where c1=10


update mytab5
set c1=13, c2=01,c3='aa'
where c1=12

update mytab5
set c1=13, c2=01,c3='aa'
where c1=12






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                                      ...

CREATE TABLE Syntax

CREATE TABLE Syntax CREATE TABLE <table-name> ( <column-list> [<constraint-list>] ). Column list with data types and optional and inline constraints. Optional external constraint list  CONSTRAINT [ ConstraintName ] <Constraint-Spec>            Primary key            Foreign key            Unique            Check CREATE TABLE Statement Example CREATE TABLE Student            ( StdNo CHAR(11),            StdFirstName VARCHAR(50),            StdLastName VARCHAR(50),            StdCity VARCHAR(50),            StdState CHAR(2),            StdZip CHAR(10),            ...

Query Formulation

Query Formulation   Query Formulation Process: Critical Questions: What tables?           - Columns in result.          - Conditions to test (including join conditions). How to combine the tables?           - Usually join of PK to FK. More complex ways to combine Individual rows or groups of rows?           - Aggregate functions in result.          - Conditions with aggregate functions. University Database Diagram: Summarization and Joins 1:      Example 1: List the number of students enrolled in each 2017 course offering showing the offer number and number of students in the result.                SELECT Offering.OfferNo,                                     COUNT (*) AS NumSt...