Week 5 Flashcards
two components of applicaiton
how does sql link
what does it link to
grpahical interface and direct query
sql is used to pull info out of
DBMS
DDL
Data definiton language
commands that define a database, including creating, altering, and dropping tables/establish constraintsML
DML
data manipulation language
commands that mainitan and query a db
DCL
data control language
commands the contral db, administer priveleges and committ data
example of ddl
create tables
establish fk
drop or truncate tables
PHYSICAL DESIGN & MAINTENACNE
emaple of dml
load the database: insert data, update data, manipulate data with SELECT
iml & maintenance
DCL example
contrl database
GRANT ADD REVOKE
imp and maintenance
major create statement
CREATE schema- define portion of db owened by 1 user
CREATE table- define anew table and its columns
CREATE VIEW- defines logical table from one or more table or views
other create statments
CREATE TABLE Test1_T
(
Test1ID int PRIMARY KEY,
FirstName varchar(40) NOT NULL,
LastName varchar(30) NOT NULL,
State char(2) NULL
);
this is the formatting!!!
CREATE TABLE name(
___ data type PK not null,
)
HOW CAN WE ALTER TABLES
Change oclumn name, add a new column, drop a column
How to end off the diff rows in the the code?
just a comma!! after each
How to end off the different sectins of code? the cunkS?
;
How to alter a table to add?
ALTER TABLE name
ADD __data type Not Null;
How to alter a table to drop
ALTER TABLE name
DROP name;
How to alter table to alter column like the data type?
ALTER TABLE name
ALTER COLUMN __ varchar(#) Null;
5 types of constraints
NOT NULL
CHECK (like >= a value)
UNQIUE
PRIMARY KEY
FOREIGN KEY
how to add a constraint?
ALTER TABLE Test2_T
ADD CONSTRAINT FK_Test2_T_Test1_T FOREIGN KEY
(EMPLOYEEID)
REFERENCES Test1_T(TestID);
- ALTER TABLE ___name___
- ADD CONSTRAINT __name of constraint___ FOREIGN KEY
- Type the foreign key you wanna add
- REFERENCES Table(Column)
MAIN CODES
CREATE TABLE__
ALTER TABLE___
How to drop a component ?
ALTER TABLE __name__
DROP __Component Type__ __ComponentName__;
COMPOENNENT TYPE: COLUMN
Insert statemetn
Adds one or more rows to a table or view
INSERT INTO name
(ColA, ColB, ColC) VALUES (1,2,3)