SQL Commands Flashcards
Alter Table
Adds new column or deletes column or index
Add
Adds a new column to the table
Drop Column
Deletes the column
Create Index # on Column
Creates an index on the table
Select
Retrieves and sorts information
Insert Into
Add a row to the table
Update, Set
Change the value of a column
What is a Procedure
Stored SQL code to be used later
select *
select any
select gender
, count (*)
from Employee
group by Gender
Shows the amount of men and women (shows the amount of people for each classification of genders)
CONCAT
Adds two or more strings together
distinct
prevents duplicates from being displayed in the query.
where
filter records displayed that meet a certain condition
or requires how many sides to be true
1
and requires how many sides to be true
both sides
IN
multiple or statements, returns all values separated by a comma.
between
selects values within a given range
union
combine results of 2 select statements with the same number of columns
Except
Exclude in first query if it happens as well in the second query
Intersect
Include queries from ONLY both rows
’%’
Return arbitrary amount of results
‘_’
Return only a single character
cross join
comparing each row of the first table with each one of the second table.
into
combine two completely different table result sets. Both tables need to be accessable
use Student16
go
select * from LobsterFarm.dbo.employee
drop table if exists
delete a table from the database (unrecoverable if there is no backup, there is no confirmation message)
go
indicates that prior commands are ready to be executed
with
allows you to give a subquery block a name
insert
insert new records into the table
update
modify existing data
delete
delete existing records