• Register
0 votes
66 views

Problem:

Hi there! I am learning SQL. Somewhere I saw a multiple choice question in which a list of terms was given and I had to choose the terms that refer to the commands used to create or modify database tables and columns. Following is the list of keywords:

  • Group By
  • Select
  • Insert
  • Update
  • Where
  • Create
  • Delete
  • Like
  • Truncate

I chose some of these as I do not know the functionality of most of these commands. I have learned only basics yet. If someone could explain all these commands, I would be grateful. Thanks!

10 8 4
9,920 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution:

Following is the list of commands that are used to create or modify tables or columns in a database:

  • Create
  • Insert
  • Update
  • Delete
  • Truncate

CREATE:

CREATE command is used to create a new table. The syntax of this command is:

CREATE TABLE table_name
(
   column_name datatype,
   coulumn_name datatype,
   .
   .
   .
);

 

INSERT:

INSERT command is used to insert the data into a table. The syntax of this command is:

INSERT INTO table_name (column1, column2, ... ,column_N)
VALUES (value1, value2, ... , value_N);

 

UPDATE:

The UPDATE command is used to change the existing records in the table. The syntax of this command is:

UPDATE table_name
SET column1 = value, column2 = value, ... ,column_N = value;

In the UPDATE command, the WHERE clause is optional. If you want to update all the records in a certain column, then you do not need to use the WHERE clause. If you want to update particular columns that fulfill some conditions, you need to use a WHERE clause. The syntax of using WHERE clause with UPDATE command is as follows:

UPDATE table_name
SET column1 = value, column2 = value, ... ,column_N = value
WHERE condition;

DELETE:

DELETE command is used to delete records from a table. The syntax of this command is:

DELETE FROM table_name;

The WHERE clause is optional in DELETE command too. If you want to remove all the records from the table, you can simply use DELETE command without WHERE clause. If you want to remove particular records from the table, then you can use the WHERE clause as follows:

DELETE FROM table_name
WHERE condition;

TRUNCATE:

The TRUNCATE command is used to remove all the data from the table but it does not affect the structure of the table. The syntax of this command is:

TRUNCATE TABLE table_name;

Following is the description of other commands:

SELECT:

The SELECT command is used to retrieve data from the table. The syntax of this command is:

SELECT Column1, Column2, ... , Column_N
FROM table_name;

GROUP BY:

This command is used to group the records according to a particular column or function. This command is used with the SELECT command. The syntax of this command is:

SELECT columns
FROM table_name
GROUP_BY column/aggregate_function;

Aggregate function refers to COUNT, MAX, MIN, SUM, AVG, etc.

WHERE:

WHERE clause is used to give a condition to be checked before doing anything on the data. It is mostly used with the SELECT command as well as can be used with several other commands. The syntax of the WHERE clause is:

some_other_command
WHERE condition;

LIKE:

LIKE command is used to match the specified pattern with the columns. It is used in the WHERE clause. Two wildcard characters are used when you do not know the exact pattern:

  • _ : Represents a single character that is unknown and could be anything. 
  • %: Represents none, single or multiple characters.

The syntax of this command is:

SELECT columns
WHERE column LIKE '%_';

 

12 7 5
27,360 points

Related questions

0 votes
1 answer 41 views
41 views
Problem: Hi there! I want to know which command is used to retrieve data from a database in SQL? How do we use it and when to use it? I am a beginner so I am looking for a detailed answer. Thanks!
asked Jan 20 Code Learner 9.9k points
0 votes
2 answers 38 views
38 views
Problem: Which of the following terms refers to a network resource sharing model that uses access control lists saved on each computer? • Intranet • Extranet • Client/server • Peer-to-peer
asked Apr 12, 2020 ArifulIslam 7.5k points
0 votes
1 answer 38 views
38 views
Problem: I want to know what are the naming conventions in SQL for naming columns? Can we use special characters? Please guide.
asked Mar 6 Code Learner 9.9k points
0 votes
1 answer 228 views
228 views
Problem: Hello! I want to know how I can delete data from the database? Is there more than one ways to do so?
asked Mar 3 Code Learner 9.9k points
0 votes
1 answer 41 views
41 views
Problem: How do we see the data that exists in a database?
asked Mar 3 Code Learner 9.9k points
0 votes
1 answer 103 views
103 views
Problem: How do we insert new records in a database?
asked Mar 3 Code Learner 9.9k points
0 votes
1 answer 37 views
37 views
Problem: I want to know how can we change the data in a database? Thanks!
asked Mar 3 Code Learner 9.9k points
1 vote
1 answer 83 views
83 views
Problem: Which of the following allows users to add, change, delete, or retrieve data in a database? a) Attribute generation b) Report generation tools c) Data dictionary d) Query wizard tool e) Data manipulation language
asked Mar 23, 2020 ArifulIslam 7.5k points
0 votes
1 answer 6 views
6 views
Problem: I have 2 Tables - Employee and Job_History and Both the tables have 3 common columns in it - EMPLOYEE_ID, JOB_ID, DEPARTMENT_ID. Now, I want to Join both the tables using JOIN but not on the basis of all 3 common columns BUT on the basis of only 2 common columns - EMPLOYEE_ID and JOB_ID. How can i get the result ?
asked Apr 26 Supti 13k points
0 votes
1 answer 13 views
13 views
Problem: I have a database named foo and a database named bar. I have a table in foo called tblFoobar that I want to move data (and all) to the database from the database bar of foo. What is the sql statement to do this?
asked Feb 27 sasha 16.2k points