WGU D426/D427 Syntax QUESTIONS AND CORRECT DETAILED ANSWERS (VERIFIED ANSWERS) ALREADY GRADED A+

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

34 Terms

1
New cards

List all Databases

SHOW DATABASES;

2
New cards

List all Tables in a database

USE Database;

SHOW TABLES;

3
New cards

List all columns and their properties in a table

SHOW COLUMNS

FROM TableName;

4
New cards

Create a Table

CREATE TABLE TableName (

ColumnName1 DataType,

ColumnName2 DataType,

ColumnName3 DataType,

...

);

5
New cards

Add a column to a table

ALTER TABLE TableName

ADD ColumnName DataType;

6
New cards

Modify a column in a table

ALTER TABLE TableName

CHANGE CurrentColumnName NewColumnName DateType;

7
New cards

Remove a column from a table

ALTER TABLE TableName

DROP ColumnName;

8
New cards

Aggregate function (single value output)

SELECT Function(Column) AS NewColumnName

FROM TableName;

9
New cards

Aggregate function (multi-value (summary) output)

SELECT LabelsColumn, FUNCTION(DataColumn)

FROM TableName

GROUP BY LabelsColumn;

10
New cards

Insert new data into a table (all columns)

INSERT INTO TableName

VALUES (Value1, Vaule2, Value3....);

11
New cards

Insert new data into a table (not all columns)

INSERT INTO TableName (Column1, Column2, Column3....)

VALUES (Value1, Value2, Value3....);

12
New cards

Insert multiple rows of data (not all columns)

INSERT INTO TableName (Column1, Column2, Column3....)

VALUES (Value1, Value2, Value3....),

(Value1, Value2, Value3....),

(Value1, Value2, Value3....);

13
New cards

Modify data in a table (specific rows)

UPDATE TableName

SET ColumnName = NewValue

WHERE Condition;

14
New cards

Modify data in a table (all rows)

UPDATE TableName

SET ColumnName = NewValue;

15
New cards

Remove data from a table

DELETE FROM TableName

WHERE Condition;

16
New cards

Remove all data from a table

DELETE FROM TableName;

17
New cards

Set a primary key on an existing table

ALTER TABLE TableName

ADD PRIMARY KEY (ColumnName);

18
New cards

Set a foreign key on an existing table

ALTER TABLE TableName

ADD FORIEGN KEY (Column) REFERENCE Table (Column);

19
New cards

Create an index on a table

CREATE INDEX IndexName ON TableName (ColumnName);

20
New cards

Output all values from a table

SELECT * FROM TableName;

21
New cards

Create a table with constraint functions

CREATE TABLE TableName (

ColumnName1 DataType Constraint1 Constraint2,

ColumnName2 DataType Constraint1

);

22
New cards

Create a table with complex constraints on numerical or date columns

CREATE TABLE TableName (

ColumnName1 DataType CHECK (ColumnName Condition),

ColumnName2 DataType CHECK (ColumnName Condition)

);

23
New cards

Create a table with complex constraints on string columns

CREATE TABLE TableName (

ColumnName1 DataType,

ColumnName2 DataType,

CHECK (ColumnName1 Constraint),

CHECK (ColumnName2 Constraint)

);

24
New cards

Create a view

CREATE VIEW ViewName AS

SELECT Column1, Column2, Column3...

FROM TableName;

25
New cards

Remove a view

DROP VIEW ViewName;

26
New cards

Sort by a column

SELECT ColumnName

FROM TableName

ORDER BY ColumnName;

27
New cards

Apply a hierarchal sort using multiple columns

SELECT Column1, Column2

FROM TableName

ORDER BY Column1, Column2;

28
New cards

Return data from 2 tables

SELECT Table1.ColumnName, Table2.ColumnName

FROM Table1

JOIN Table2

ON Table1.ColumnName = Table2.ColumnName;

29
New cards

Return specific records from a table

SELECT Column1, Column2

FROM TableName

WHERE Condition;

30
New cards

Set a primary key when creating a table

CREATE TABLE TableName (

ColumnName1 DataType,

ColumnName2 DataType,

ColumnName3 DataType,

...

PRIMARY KEY (Column)

);

31
New cards

Set a foreign key when creating a table

CREATE TABLE TableName (

ColumnName1 DataType,

ColumnName2 DataType,

ColumnName3 DataType,

...

FOREIGN KEY (Column) REFERENCES Table (Column)

);

32
New cards

Return data from 3 or more tables

SELECT Table1.Column, Table2.Column, Table3.Column

FROM Table1

JOIN Table2

ON Table1.Column = Table2.Column

JOIN Table3

ON Table1.Column = Table3.Column;

33
New cards

Select output data based on aggregate results

SELECT LabelColumn, FUNCTION(DataColumn)

FROM TableName

GROUP BY LabelColumn

HAVING Condition;

34
New cards

Use a sub-query

SELECT Column1, Column2, Column3...

FROM TableName

WHERE Column OPERATOR

(Select FUNCTION(Column)

FROM TableName)

;