SQL Flashcards

1
Q

Selecione as colunas da tabela “actor” e filtre pelos nomes iniciados pela letra A

use o comando LIKE

A

select *
from actor
where first_name like ‘a%’
lllllllllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Selecione as colunas da tabela “actor” e filtre apenas os 10 primeiros resultados

use o comando LIMIT

A

select *
from actor
limit 10
llllllllllllllllllllllllllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Selecione as colunas da tabela “actor” e filtre os resultados de 6 a 15

use o comando LIMIT

A

select *
from actor
limit 5, 10
llllllllllllllllllllllllllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Selecione as colunas da tabela “actor” e filtre os resultados que contenham a letra A

use o comando REGEXP

A

select *
from actor
where first_name regexp ‘a’
lllllllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Selecione as colunas da tabela “actor” e filtre os resultados que comecem com a letra A

use o comando REGEXP

A

select *
from actor
where first_name regexp ‘^a’
lllllllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Selecione as colunas da tabela “actor” e filtre os resultados que comecem com a letra A e com a letra C

use o comando REGEXP

A

select *
from actor
where first_name regexp ‘^a|^c’
lllllllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Selecione as colunas da tabela “actor” e filtre os resultados que comecem com as letras CA, DA e SA

use o comando REGEXP

A

select *
from actor
where first_name regexp ‘^[cds]a’
llllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Selecione as colunas da tabela “address” e filtre os resultados cujo distrito seja California, Buenos Aires ou England

use o comando IN

A

select *
from address
where district in (‘California’, ‘Buenos Aires’, ‘England’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Selecione as colunas
“customer_id”, “first_name” e “last_name” da tabela “customer”
e una com as colunas
“rental_id” e “amount” da tabela “payment”

use o comando JOIN
use ALIAS para nomear as tabelas CUSTOMER e PAYMENT

A

select
customer.customer_id,
customer.first_name,
customer.last_name,
payment.rental_id,
payment.amount
from customer
join payment on customer.customer_id = payment.payment_id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Insira um novo idioma na tabela “language”

A

insert into language
values (
default,
‘Portuguese’,
‘2006-02-15 05:02:20’
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Insira uma nova cidade na tabela “city”

A

insert into city
values (
default,
‘Três Corações’,
15,
‘2023-09-26 16:45:00’
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Crie uma cópia de uma tabela

A

create table payment_backup as
select * from payment
lllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Atualize o valor da coluna “amount” da tabela PAYMENT, cujo payment_id é igual a 1

A

update payment
set amount = 8.99
where payment_id = 1
llllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Delete um registro de alguma tabela

A

DELETE FROM payment
WHERE payment_id = 16049
lllllllllllllllllllllllllllllllllllll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Liste o menor valor, o maior valor, a média, soma e o número de vendas do funcionário 1

A

SELECT
MAX(amount) as “Valor máximo”,
MIN(amount) as “Valor mínimo”,
AVG(amount) as “Média”
SUM(amount) as “Vendas Totais”
COUNT(amount) as “Número de vendas”
FROM payment
WHERE staff_id = 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A