Section 1

Preview this deck

DROP a FOREIGN KEY Constraint

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (21)

Section 1

(21 cards)

DROP a FOREIGN KEY Constraint

Front

mysql ALTER TABLE Orders DROP FOREIGN KEY FK_PersonOrder; Oracle ALTER TABLE Orders DROP CONSTRAINT FK_PersonOrder;

Back

having

Front

SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country HAVING COUNT(CustomerID) > 5;

Back

foreign key in create table example

Front

CREATE TABLE Orders ( OrderID int NOT NULL, OrderNumber int NOT NULL, PersonID int, PRIMARY KEY (OrderID), FOREIGN KEY (PersonID) REFERENCES Persons(PersonID) );

Back

select firstname from table customers with alias fname;

Front

select firstname as fname from customers;

Back

add a phone column to table customers using a variable character of length 11

Front

alter table customers add (phone varchar2(11));

Back

would you insert all values into a table with an auto increment primary key?

Front

no. example table persons with auto increment id: INSERT INTO Persons (FirstName,LastName) VALUES ('Lars','Monsen');

Back

join multiple tables query

Front

select --* customers.state , books.title , books.isbn from customers join orders on orders.customer# = customers.customer# join orderitems on orderitems.order# = orders.order# join books on books.isbn = orderitems.isbn order by --customers.customer# customers.state ;

Back

show info for table customers;

Front

describe customers; desc customers;

Back

add a primary key for ID in a table

Front

CREATE TABLE Persons ( ID int NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID) );

Back

group by

Front

SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s)

Back

make a table named customers with first name, last name, age, and email columns

Front

create table customers (fname varchar2(20), lname varchar2(20), age number(3), email varchar2(40));

Back

count( ) sum( ) avg( )

Front

SELECT sum(column_name) FROM table_name WHERE condition; SELECT COUNT(column_name) FROM table_name WHERE condition; SELECT avg(column_name) FROM table_name WHERE condition;

Back

LIKE

Front

WHERE CustomerName LIKE 'a%'Finds any values that start with "a" WHERE CustomerName LIKE '%a'Finds any values that end with "a" WHERE CustomerName LIKE '%or%'Finds any values that have "or" in any position WHERE CustomerName LIKE '_r%'Finds any values that have "r" in the second position WHERE CustomerName LIKE 'a_%_%'Finds any values that start with "a" and are at least 3 characters in length WHERE ContactName LIKE 'a%o'Finds any values that start with "a" and ends with "o"

Back

what command removes all rows from a table

Front

truncate table tableName;

Back

select all from books

Front

select * from books;

Back

update rows in a table

Front

UPDATE table_name SET column1 = value1, column2 =value2, ... WHERE condition;

Back

modify column fname in table customers to variable character length of 15

Front

alter table customers modify (fname varchar(15));

Back

min( ) max( )

Front

SELECT MIN(column_name) FROM table_name WHERE condition; SELECT MAX(column_name) FROM table_name WHERE condition;

Back

what command puts a new tow of data into a table

Front

insert into tableName ( value, value, value);

Back

remove table books

Front

drop table books;

Back

foreign key alter table

Front

ALTER TABLE Orders ADD FOREIGN KEY (PersonID)REFERENCES Persons(PersonID); with constraint name ALTER TABLE Orders ADD CONSTRAINT FK_PersonOrder FOREIGN KEY (PersonID) REFERENCESPersons(PersonID);

Back