SQL Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How do you order by in SQL

A

ORDER BY DataPublished Desc (autimatically does it by ascending if you dont put desc)

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

How to create a table

A

CREATE TABLE TableName
(
Attribute1 INTEGER NOT NULL, PRIMARY KEY
Attribute2 VARCHAR(20) NOT NULL
)

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

What do you have to include when making a table

A

Wether it is a primary key, its data type and wether it must be filled in (“not null”)

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

Obscure data types

A

CHAR(n), VARCHAR(n), DATE,TIME,CURRENCY

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

N in char v N in varchar

A

In char it means it must be that length but in varchar that is just the max length

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

Alter adding column

A

Alter Table TableName
ADD attributeX and their datatypesD

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

Alter deleting collumn

A

ALTER table tablename
drop column attribute x

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

Alter modyfying data type of column

A

ALTER TABLE tablename
modify column attribute x newdatatype

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

Insert new record into database

A

INSERT INTO (Column 1m column 2 )
VALUES( value1,value2)

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

Update record in data base

A

Update tablename
set column 1=x, column2=y
wheree column x=value

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

Delete row from table

A

Delete from table
where columnx=value

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

nested select

A

Select firstName, secondName
FROM people
where favfoodID=
(select foodID
FROM foods
where foodname=”cheese”)

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

Join

A

Select people. firstname, people, secondmame
from people
join foods on people.favouritefoodID=foods.foodid
where foods.foodname=”cheese”

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