week 4 Flashcards

1
Q

How is date formated in SQL

A

yyyy-mm-dd

Oct 26 2004 ——> 2004-10-26

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

How is time formated

A

hh-mm-ss

15:43 ———-> 15-43-21 (15:43:21)

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

what is the format of Create table

A

Create Table (department name)(
specify attributes
.
.
.
Specify what the primary key is , unique keys, foreign keys etc

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

base tables (tables create through a CREATE TABLE statement ) stored on a file by dbms

Virtual tables( created by a CREATE VIEW statement) not stored on a file

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

How does select work

A

select [Attribute name}
From [ The table]
where [ Condition]

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

How does Drop table [table name] RESTRICT work

A

Table is only dropped if not referenced in constraints (eg dependencies between relations through foreign keys …)

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

Drop table cascade

A

ANy dependency is removed along with the table eg( foreign keys)

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

Drop

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

ORDER BY

A

DOESNT CHANGER ORDER OF COLUMNS
eg ORDER BY name ( if nothing here default is ascending)
will order all the instances of name in ascending order

IF there is ORDER BY name asc, studentID desc (asc = ascending , desc = descending)

it will order them by name first and if any tuples have the same name, it will order those that have same name by student id ( in descending order)

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

<>

A

comparison operator that means NOT EQUAL TO
Usually seen in where statements in sql

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

In

A

eg
select * (all information , all attributes)
From student
where name IN(‘Kate’ , ‘Claire’ , Mike);

selects rows from student where students names are either kate claire or mike

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

How does alter work when adding something
Try add a constraint

A

ALTER TABLE EMPLOYEE
ADD FOREIGN KEY (DNO) REFERENCES DEPARTMENT (Dnumber);

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

How does alter work when dropping something
Try dropping a constraint

A

ALTER TABLE DEPARTMENT
DROP FOREIGN KEY (MGRSSN);

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

How does Delete work

A

DELETE FROM <table name>
WHERE <condition></condition>

DELETE FROM EMPLOYEE
WHERE LNAME=’Brown’

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

How does update work

A

UPDATE PROJECT
SET PLOCATION = ‘Bellaire’,
DNUM = 5
WHERE PNUMBER=10;

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