sql Flashcards
What is SQL and how is it different from languages like JavaScript?
SQL is a declarative programming language where programmers describe what they want to see and the environment comes up with the necessary processes to provide something accurate
How do you retrieve specific columns from a database table?
select “columnname”
How do you filter rows based on some specific criteria?
use where “columnname” = ‘value’
What are the benefits of formatting your SQL?
reusability and organization
What are four comparison operators that can be used in a where clause?
=, , !=
How do you limit the number of rows returned in a result set?
limit x where x is an integer
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
order by
How do you add a row to a SQL table?
use insert into “table” (“columnname1”, “columnname2”, “columnnameX”)
values (‘value1’, ‘value2’, ‘valueX’);
What is a tuple?
a list of values
ex: values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’)
How do you add multiple rows to a SQL table at once?
add multiple tuples separated by a comma
How do you get back the row being inserted into a table without a separate select statement?
returning * to receive everything or returning “columnnameX” to receive certain columns
How do you update rows in a database table?
update “table”
set “columnname” = ‘value’;
Why is it important to include a where clause in your update statements?
otherwise, every row gets updated
How do you delete rows from a database table?
delete from “table”
where “columnname” = ‘value’;