In: Computer Science
Question 3. Issue the following statement to create a copy of the d_clients table named d_clients_copy and write ONE statement to update this table. create table d_clients_copy as select * from d_cliens Change the phone number for Hiram Peters to 5551212 and email to [email protected]
Hello,
Good Day!
/* Create a table called d_clients*/
CREATE TABLE d_clients(Name varchar(20), Phone int, email
varchar(50));
/* Inserting records in to table d_clients */
INSERT INTO d_clients VALUES('Hiram
Peters',5551210,'[email protected]');
/* Display all the records from the table */
SELECT * FROM d_clients;
Output:
Hiram Peters|5551210|[email protected]
Solution:
/*create a copy of the d_clients table named d_clients_copy and write ONE statement to update this table. create table d_clients_copy as select * from d_cliens Change the phone number for Hiram Peters to 5551212 and email to [email protected] */
create table
d_clients([name] varchar(20),phone int,email varchar(50));
insert into d_clients ([name],phone,email) values('Hiram
Peter',5551210,'[email protected]');
insert into d_clients ([name],phone,email)
values('David',5551211,'[email protected]');
select * from d_clients;
select [name],case
when[name]='Hiram Peter' then 5551212 else phone end AS phone,email
into d_clients_copy from d_clients;
select * from d_clients_copy;
This query will create table d_clients_copy with d_clients skeleton and the value of the one record in the table will be replaced with phone 5551212 and email "[email protected]".
Thank you!