Create a table salesman with 4 attributes [ID, Name, Department and Commission], insert minimum 3 tuples and write a query to update Department to 'CSE' whose id is 2.
Answers
Answer:
For creating the table, a simple SQL query has to be fired:
create table salesman (ID int primary key, Name varchar(30) not null, Department varchar(50), Commission double default '0.0');
Inserting tuples:
insert into salesman values (1, 'Abcd', 'Department1', 45005.5);
insert into salesman values (2, 'Efgh', 'Department2', 0.0);
insert into salesman values (3, 'Ijkl', 'Department3', 8032.6);
Updating value:
update salesman set Department = "CSE" where id = 2;
Explanation:
For creating a table, we use the CREATE query in SQL. The syntax is as follows:
create table <table_name> ( <attribute1> <datatype1> <constraint1> , <attribute2> <datatype2> <constraint2> , .... );
Insertion query takes the column names for which you want to insert the data. If no column names are specified, then it is assumed that all columns are to be affected:
insert into <table_name> ( <optional_column_names> ) values ( <values_to_be_inserted> );