Tuesday, 21 August 2012

MySql Queries

MySql Queries
There are two parts of Mysql Database, which are used to create complete database. Database is using many platforms like in website, software etc


  1. Data Manipulation Language.
  2. Data defination Language.

  1. Data Manipulation Language(DML):
Create table Student
(SID                     NUMBER ,
NAME                CHAR(20)          NOT NULL,
ADDRESS           VARCHAR(50),
CONSTRAINT   MY1          PRIMARY KEY (SID));

ALTER TABLE STUDENT
DROP        CONSTRAINT             MY1;

ALTER TABLE STUDENT
ADD          CONSTRAINT   MY1          PRIMARY KEY  (SID);


ALTER TABLE STUDENT
ADD          CITY           CHAR(10);

INSERT     INTO         STUDENT (SID, NAME)
VALUES(2, “ADEEL”);


CREATE TABLE          COURSE
(CC             CHAR(6),
TITLE         CHAR(20),
CREDITS   NUMBER,
CONSTRAINT             COURSEPK                 PRIMARY KEY  (CC));

CREATE TABLE          REGISTER
(SID           NUMBER,
COURSE             CHAR(10),
DOR                    DATE,
CONSTRAINT   REGFK1    FOREIGN              KEY (SID)       
REFERENCES   STUDENT,
CONSTRAINT   REGFK2    FOREIGN KEY (COURSE) REFERENCES COURSE);

    2. Data defination Language:

SELECT * FROM TABLE_NAME WHERE ID=4;

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

0 comments:

Post a Comment