Consider the Table temperature_details in Keyspace “day3” with schema as follows:
temperature_details(daynum, year, month, date, max_temp)
with primary key(daynum, year, month, date)
There exists same maximum temperature at different hours of the same day. Choose the correct CQL query to:
Alter table temperature_details to add a new column called “seasons” using map of type represented as . Season can have the following values season={spring, summer, autumn, winter}.
Update table temperature_details where columns daynum, year, month, date bore the following values- 4317,1955,7,26 respectively.
Use the select statement to output the row after updation.
Note: A map relates one item to another with a key-value pair. For each key, only one value may exist, and duplicates cannot be stored. Both the key and the value are designated with a data type.
cqlsh:day3> alter table temperature_details add hours1 set;
cqlsh:day3> update temperature_details set hours1={1,5,9,13,5,9} where daynum=4317;
cqlsh:day3> select * from temperature_details where daynum=4317;
cqlsh:day3> alter table temperature_details add seasons map;
cqlsh:day3> update temperature_details set seasons = seasons + {7:'spring'} where daynum=4317 and year =1955 and month = 7 and date=26;
cqlsh:day3> select * from temperature_details where daynum=4317 and year=1955 and month=7 and date=26;
cqlsh:day3>alter table temperature_details add hours1 list;
cqlsh:day3> update temperature_details set hours1=[1,5,9,13,5,9] where daynum=4317 and year = 1955 and month = 7 and date=26;
cqlsh:day3> select * from temperature_details where daynum=4317 and year=1955 and month=7 and date=26;
cqlsh:day3> alter table temperature_details add seasons map;
cqlsh:day3> update temperature_details set seasons = seasons + {7:'spring'} where daynum=4317;
cqlsh:day3> select * from temperature_details where daynum=4317
Answers
Answered by
0
there are many websites which helps you
nknaveenmudra:
can u say the answer please bro
Answered by
0
Answer: cqlsh:day3> alter table temperature_details add seasons map<varint,text>;
cqlsh:day3> update temperature_details set seasons = seasons + {7:'spring'} where daynum=4317 and year =1955 and month = 7 and date=26;
cqlsh:day3> select * from temperature_details where daynum=4317 and year=1955 and month=7 and date=26;
Explanation:
cqlsh:day3> alter table temperature_details add seasons map<varint,text>;
cqlsh:day3> update temperature_details set seasons = seasons + {7:'spring'} where daynum=4317 and year =1955 and month = 7 and date=26;
cqlsh:day3> select * from temperature_details where daynum=4317 and year=1955 and month=7 and date=26;
a) Add column “seasons”
cqlsh:day3> alter table temperature_details add seasons map;
b) Update table
cqlsh:day3> update temperature_details set seasons = seasons + {7:'spring'} where daynum=4317 and year =1955 and month = 7 and date=26;
c) Select query
cqlsh:day3> select * from temperature_details where daynum=4317 and year=1955 and month=7 and date=26;
daynum year month date hours hours1 max_temp seasons
4317 1955 7 26 {1,5,9,13} {1,5,9,13,5,9} 16.7 {7:’spring’}
Similar questions