This document provides SQL syntax examples for performing various operations on database tables such as creating a table, inserting and retrieving data, modifying columns, adding or dropping columns, renaming tables, assigning default values, ordering and grouping data, creating and dropping views, using where and like clauses, updating and deleting data, truncating tables, and dropping tables. Some key operations demonstrated include creating a table, inserting data, selecting data, altering tables by modifying or dropping columns, renaming tables, assigning default values to columns, and creating and dropping views.
This document provides SQL syntax examples for performing various operations on database tables such as creating a table, inserting and retrieving data, modifying columns, adding or dropping columns, renaming tables, assigning default values, ordering and grouping data, creating and dropping views, using where and like clauses, updating and deleting data, truncating tables, and dropping tables. Some key operations demonstrated include creating a table, inserting data, selecting data, altering tables by modifying or dropping columns, renaming tables, assigning default values to columns, and creating and dropping views.
create table number_of_bottles Int) to check table created desc table_name to retrieve data from table or view select * from table_name to delete a column within the table alter table table_name drop column column_name alter table table_name modify auspicious_day int to modify column type (changed from Varchar to int) to add column alter table table_name add (cost int) to rename the table rename table_name to yarrows_party to insert values into table insert into yarrows_party values ('02-May-2020', 'Saturday', 'Blender's Pride', '2', '3000') to insert values from one table to insert into yarrows_party(Date_column,auspicious_day,brand,number_of_bottles,cost) another select Date_column,auspicious_day,column3,number_of_bottles,cost from AllHail_Nithya alter table yarrows_party modify (Date_column default sysdate) to assign default values alter table yarrows_party modify auspicious_day default 'Friday' order by select * from yarrows_party order by auspicious_day group by select auspicious_day,sum(cost) from yarrows_party group by auspicious_day create view create view Party_success as select auspicious_day, number_of_bottles, cost from yarrows_party drop view drop view Party_success select * from yarrows_party where brand = 'Blender's Pride' (where command is used to specify a condition) Where (where can be used along with select, update and delete commands) select * from yarrows_party where brand like 'B%' (returns values that start with B select * from yarrows_party where brand like '%P%' Like (returns value that has letter 'P' in it) Update & Set update yarrows_party set brand='Green Label' delete the row delete from yarrows_party where brand = 'Blender's Pride' and auspicious_day = 'Saturday' truncate table yarrows_party truncate the table (all values are deleted from the table but table strcuture is intact) drop table yarrowa_party drop view (entire table is deleted