SlideShare uma empresa Scribd logo
1 de 6
BASIC DATABASE(MYSQL) QUERIES

1. create database dbname;

  This statement is used to create new database.

2. show databases;
   You can check available databases using show.
3. use dbname;
    When you have multiple databases in your SQL Schema, then before starting your
   operation, you would need to select a database where all the operations would be
   performed. The SQL USE statement is used to select any existing database in SQL
   schema.
4. show tables;
   You can check available tables in specific database using show.
5. create table tname(c1name c1type, c2name c2type, c3name c3type……cnname
   cntype)
   The above statement is used to create new table, it requires to specify the column
   names and type. Type indicates the data to be entered in specific column.
    create table student(sname varchar(25), sroll int, sage int);
6. describe tname
    To view the structure of table, we use describe statement, Suppose if we had
   deleted all the records of the table or the table is empty, and we want to insert new
   record, we must know the structure of the table, ie column name and its datatype.
   The output of describe would look like this.. for ex: describe employee_record

        Field                   Type                  Null
        Ename                   Varchar               yes
        Salary                  Int                   Yes


7. INSERT

   Insert query is use to fill the table or add content to the specific table. It can be used
   in following ways:

         insert into tname values(c1value,c2 value, c3value……cnvalue);

      To insert data in table

         insert into tname (c1name, c3name, c7name,..cnname)values(c1value,
             c7value,..cnvalue);
       To insert data in specific columns only not in all the columns, we need to
      specify the column names.
         insert into t1name( c1name,c2name..cnname)
         select c1name,c2name..cnname from t2name;
      This syntax is used to populate table with data in other existing table.
In the above snapshot we are inserting data into parent table using the data in
child table.


     8. DELETE(Delete query doesnot use *)

     Delete query is used to remove record or delete some record from specific table. If
     delete query is used without Where clause, it will delete all the data in the table.

           Delete from tname where some condition.
           Delete from student where roll_no =4;
           Delete from tname;
           Empty the table
           Delete from tname where age =(select max(age) from tname);
           Delete the record of student whose age is maximum.
In the above snapshop we have deleted all the records where eid and
      eno are same or equal…. In the same way we can apply any condition.

9. SELECT

Select query is used to view the contents of specific table, it can be used as:

      Select * from tname;
      To view all the contents of table. Here * stands for all.
      Select c1name,c2name…cnname from tname;
      To view records of specific columns/fields. For ex select sname from student.
Select * from tname where some condition.
      To view all the contents of table that satisfies the given condition. For ex: select
      * from employee where salary > 10000;

      Select distinct(c1name) from tname;
      To view unique values or unrepeated values of the table’s particular column. For
      ex: select distinct(sname) from student.
      Select count(cname) from tname.
      Counts the no. of records in specific column. for ex: select count(sname) from
      student.
      Select count(distinct(cname)) from tname.
      Counts the distinct no. of records in specific field. For ex: select
      count(distinct(sname)) from student.



10. DROP

Drop query is used to remove table from selected database or to remove whole
database.

      Drop database dbname
      Drop table tname.



11. ALTER (alter query needs the word table explicitly)

Alter query is generally used to change the structure of the table, either by
adding new column or deleting existing column.

      Alter table tname ADD newcname newctype;
      Above statement can be used to add new column to the existing table. Say alter
      table student add parent_name varchar(45);
      Alter table tname DROP cname.
      Above statement can be used to delete existing column from an existing table.
      Say alter table student drop parent_name;
      Alter table tname rename to new_tname;
Above statement can be used to change the name of existing table. For ex: alter
   table student rename to student_record;


12. UPDATE

Update query is used to change the data resinding in the table. Or to change the
content of table, if update query is used without where clause, it will change all the
records of specific column.

Update tname set cname= whatever where some condition.

Update the record of table which satisfies the given condition.

Update student SET age=20 where roll_no =1;

Above statement will change the age to 20 of the student whose rollno is1.Here
student is the table name, age is the columnname and roll_no is another column
name.

                   OR

Update student set sname=’arti sharma’ where roll_no=2.

Above statement will change the name to arti sharma of the student whose rollno
is2.Here student is the table name, sname is the columnname and roll_no is another
column name.

                   OR

Update student set age=20;

 Above statement will change the age of all the students because we have not
specified any condition using where clause.

Mais conteúdo relacionado

Mais procurados (17)

Lecture 3 sql {basics ddl commands}
Lecture 3 sql {basics  ddl commands}Lecture 3 sql {basics  ddl commands}
Lecture 3 sql {basics ddl commands}
 
Ddl commands
Ddl commandsDdl commands
Ddl commands
 
Lecture 4 sql {basics keys and constraints}
Lecture 4 sql {basics  keys and constraints}Lecture 4 sql {basics  keys and constraints}
Lecture 4 sql {basics keys and constraints}
 
Data Definition Language (DDL)
Data Definition Language (DDL) Data Definition Language (DDL)
Data Definition Language (DDL)
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Alter table command
Alter table commandAlter table command
Alter table command
 
Mysql alter-command
Mysql alter-commandMysql alter-command
Mysql alter-command
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
ADBMS Unit-II c
ADBMS Unit-II cADBMS Unit-II c
ADBMS Unit-II c
 
Chapter9 more on database and sql
Chapter9 more on database and sqlChapter9 more on database and sql
Chapter9 more on database and sql
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
DML Commands
DML CommandsDML Commands
DML Commands
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
Sql reference from w3 schools
Sql reference from w3 schools Sql reference from w3 schools
Sql reference from w3 schools
 
Sql tables
Sql tablesSql tables
Sql tables
 
SQL
SQLSQL
SQL
 

Destaque

c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlideharman kaur
 
Introduction to digital electornics
Introduction to digital electornicsIntroduction to digital electornics
Introduction to digital electornicsharman kaur
 
Sales. Doing it Sillicon Valley style.
Sales. Doing it Sillicon Valley style.Sales. Doing it Sillicon Valley style.
Sales. Doing it Sillicon Valley style.Artem Berman
 
An overview of Ukrainian it market.
An overview of Ukrainian it market.An overview of Ukrainian it market.
An overview of Ukrainian it market.Artem Berman
 
Content Marketing at Kelloggs - BI MN
Content Marketing at Kelloggs - BI MNContent Marketing at Kelloggs - BI MN
Content Marketing at Kelloggs - BI MNKarl Miller
 
Quiz on Logic Gate
Quiz on Logic GateQuiz on Logic Gate
Quiz on Logic Gateharman kaur
 
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)harman kaur
 
Virtual function
Virtual functionVirtual function
Virtual functionharman kaur
 
Creating red black tree
Creating red black treeCreating red black tree
Creating red black treeharman kaur
 
Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)harman kaur
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++harman kaur
 
Rules of inference
Rules of inferenceRules of inference
Rules of inferenceharman kaur
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programsharman kaur
 

Destaque (19)

Diploma3
Diploma3Diploma3
Diploma3
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
 
Presentation job fair
Presentation   job fairPresentation   job fair
Presentation job fair
 
Digital u1
Digital u1Digital u1
Digital u1
 
Introduction to digital electornics
Introduction to digital electornicsIntroduction to digital electornics
Introduction to digital electornics
 
Sales. Doing it Sillicon Valley style.
Sales. Doing it Sillicon Valley style.Sales. Doing it Sillicon Valley style.
Sales. Doing it Sillicon Valley style.
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
Najed
NajedNajed
Najed
 
An overview of Ukrainian it market.
An overview of Ukrainian it market.An overview of Ukrainian it market.
An overview of Ukrainian it market.
 
Content Marketing at Kelloggs - BI MN
Content Marketing at Kelloggs - BI MNContent Marketing at Kelloggs - BI MN
Content Marketing at Kelloggs - BI MN
 
Diploma5
Diploma5Diploma5
Diploma5
 
Quiz on Logic Gate
Quiz on Logic GateQuiz on Logic Gate
Quiz on Logic Gate
 
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
ਜਪੁ ਜੀ ਸਾਹਿਬ (JAPJI SAHIB)
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Creating red black tree
Creating red black treeCreating red black tree
Creating red black tree
 
Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++
 
Rules of inference
Rules of inferenceRules of inference
Rules of inference
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 

Semelhante a Msql query

Semelhante a Msql query (20)

unit-5 sql notes.docx
unit-5 sql notes.docxunit-5 sql notes.docx
unit-5 sql notes.docx
 
Oracle : DML
Oracle : DMLOracle : DML
Oracle : DML
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Intro to tsql unit 9
Intro to tsql   unit 9Intro to tsql   unit 9
Intro to tsql unit 9
 
Sql basics v2
Sql basics v2Sql basics v2
Sql basics v2
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
 
ADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptxADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptx
 
SQL : Structured Query Language
SQL : Structured Query LanguageSQL : Structured Query Language
SQL : Structured Query Language
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
 
dbms lab manual
dbms lab manualdbms lab manual
dbms lab manual
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsgADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
 
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
Class XII-UNIT III - SQL and MySQL Notes_0.pdfClass XII-UNIT III - SQL and MySQL Notes_0.pdf
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
SQL report
SQL reportSQL report
SQL report
 
SQL
SQLSQL
SQL
 

Último

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Último (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Msql query

  • 1. BASIC DATABASE(MYSQL) QUERIES 1. create database dbname; This statement is used to create new database. 2. show databases; You can check available databases using show. 3. use dbname; When you have multiple databases in your SQL Schema, then before starting your operation, you would need to select a database where all the operations would be performed. The SQL USE statement is used to select any existing database in SQL schema. 4. show tables; You can check available tables in specific database using show.
  • 2. 5. create table tname(c1name c1type, c2name c2type, c3name c3type……cnname cntype) The above statement is used to create new table, it requires to specify the column names and type. Type indicates the data to be entered in specific column. create table student(sname varchar(25), sroll int, sage int); 6. describe tname To view the structure of table, we use describe statement, Suppose if we had deleted all the records of the table or the table is empty, and we want to insert new record, we must know the structure of the table, ie column name and its datatype. The output of describe would look like this.. for ex: describe employee_record Field Type Null Ename Varchar yes Salary Int Yes 7. INSERT Insert query is use to fill the table or add content to the specific table. It can be used in following ways: insert into tname values(c1value,c2 value, c3value……cnvalue); To insert data in table insert into tname (c1name, c3name, c7name,..cnname)values(c1value, c7value,..cnvalue); To insert data in specific columns only not in all the columns, we need to specify the column names. insert into t1name( c1name,c2name..cnname) select c1name,c2name..cnname from t2name; This syntax is used to populate table with data in other existing table.
  • 3. In the above snapshot we are inserting data into parent table using the data in child table. 8. DELETE(Delete query doesnot use *) Delete query is used to remove record or delete some record from specific table. If delete query is used without Where clause, it will delete all the data in the table. Delete from tname where some condition. Delete from student where roll_no =4; Delete from tname; Empty the table Delete from tname where age =(select max(age) from tname); Delete the record of student whose age is maximum.
  • 4. In the above snapshop we have deleted all the records where eid and eno are same or equal…. In the same way we can apply any condition. 9. SELECT Select query is used to view the contents of specific table, it can be used as: Select * from tname; To view all the contents of table. Here * stands for all. Select c1name,c2name…cnname from tname; To view records of specific columns/fields. For ex select sname from student.
  • 5. Select * from tname where some condition. To view all the contents of table that satisfies the given condition. For ex: select * from employee where salary > 10000; Select distinct(c1name) from tname; To view unique values or unrepeated values of the table’s particular column. For ex: select distinct(sname) from student. Select count(cname) from tname. Counts the no. of records in specific column. for ex: select count(sname) from student. Select count(distinct(cname)) from tname. Counts the distinct no. of records in specific field. For ex: select count(distinct(sname)) from student. 10. DROP Drop query is used to remove table from selected database or to remove whole database. Drop database dbname Drop table tname. 11. ALTER (alter query needs the word table explicitly) Alter query is generally used to change the structure of the table, either by adding new column or deleting existing column. Alter table tname ADD newcname newctype; Above statement can be used to add new column to the existing table. Say alter table student add parent_name varchar(45); Alter table tname DROP cname. Above statement can be used to delete existing column from an existing table. Say alter table student drop parent_name; Alter table tname rename to new_tname;
  • 6. Above statement can be used to change the name of existing table. For ex: alter table student rename to student_record; 12. UPDATE Update query is used to change the data resinding in the table. Or to change the content of table, if update query is used without where clause, it will change all the records of specific column. Update tname set cname= whatever where some condition. Update the record of table which satisfies the given condition. Update student SET age=20 where roll_no =1; Above statement will change the age to 20 of the student whose rollno is1.Here student is the table name, age is the columnname and roll_no is another column name. OR Update student set sname=’arti sharma’ where roll_no=2. Above statement will change the name to arti sharma of the student whose rollno is2.Here student is the table name, sname is the columnname and roll_no is another column name. OR Update student set age=20; Above statement will change the age of all the students because we have not specified any condition using where clause.