• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 4 pages
Exam (elaborations)

C170 Data Management - Applications SQL Syntax

Document preview thumbnail
Preview 1 out of 4 pages

CREATE TABLE syntax DDL CREATE TABLE tableName ( colName dataType constraint INDEX indexName (colName) PRIMARY KEY (colName, colName) or colName dataType PRIMARY KEY FOREIGN KEY (colName, colName) REFERENCES tableName (colName) ); CREATE INDEX syntax DDL CREATE [UNIQUE] INDEX indexName ON tableName (colName); UNIQUE should only be used on a column that should not have duplicate values. DROP INDEX syntax DDL DROP INDEX indexName; DROP INDEX 'PRIMARY' ON tableName; drops PK ALTER INDEX DDL ALTER INDEX indexName ON tableName (colName, colName); INSERT command syntax DML INSERT INTO tableName VALUES (val1, val2, val3...); For inserting new rows into existing table. UPDATE syntax DML UPDATE tableName SET colName = expression {ex. PRICE = 4.00} WHERE condition; {ex. S_NUMBER = A123} For modifying data in a table DELETE syntax DML DELETE FROM tableName WHERE condition; {ex. PRICE 3.00} For deleting rows from a table ALTER TABLE syntax DDL ALTER TABLE tableName ADD (colName, dataType); or ALTER TABLE tableName ADD INDEX indexName (colName); or ALTER TABLE tableName ADD PRIMARY KEY (colName); or ALTER TABLE tableName ADD FOREIGN KEY (colName) REFERENCES tableName; ALTER TABLE tableName DROP COLUMN colName; or DROP CONSTRAINT constraintName; or DROP PRIMARY KEY; or DROP INDEX indexName; ALTER TABLE tableName MODIFY (colName dataType); For changing a columns data characteristics. To copy a table and populate it from existing table DDL CREATE TABLE newTableName (create table parameters); then INSERT INTO newTableName (newColList) SELECT existingColList FROM existingTable Name; or CREATE TABLE newTableName AS SELECT oldCol1 AS newCol1, oldCol2 AS newCol2 FROM existingTableName; or CREATE TABLE....LIKE followed by INSERT INTO...SELECT Creates DB if it does not already exist DDL CREATE DATABASE IF NOT EXISTS dbName CREATE VIEW DDL CREATE VIEW viewName AS SELECT query FROM tableName; Changing a VIEW DDL ALTER VIEW Subquery DML SELECT colName FROM tableName WHERE colName = (SELECT colName FROM tableName WHERE condition);


Document information

Uploaded on
September 3, 2023
Number of pages
4
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$14.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
FREEMANSHARP
3.6
(29)
Sold
150
Followers
70
Items
7608
Last sold
2 months ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.