SQL DDL - DDL Data Definition Language Murach Chapters 10...

Info icon This preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
DDL: Data Definition Language Murach Chapters 10 and 11
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
SQL: Structured Query Language DDL CREATE ALTER DROP DCL GRANT REVOKE DENY DML SELECT INSERT UPDATE DELETE
Image of page 2
DDL: Data Definition Language CREATE TABLE CREATE INDEX ALTER TABLE DROP TABLE DROP INDEX There are many other variations of the CREATE, ALTER and DROP commands
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Create Table Syntax CREATE TABLE table_name ( column_name_1 column_name_2 column_name_N table_attributes ) data_type data_type data_type attributes , attributes , ... attributes , Note: SQL is case insensitive and “spacing” insensitive
Image of page 4
Create Table Syntax CREATE TABLE table_name ( column_name Use letters & digits No reserved words Avoid special symbols [First Name] data_type attributes ,
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Create Table Syntax CREATE TABLE table_name ( column_name data_type Char(X) NChar(X) Varchar(X) NVarchar(X) Int Decimal(X,Y) Money Datetime (and many other data types) attributes ,
Image of page 6
Create Table Syntax CREATE TABLE table_name ( column_name data_type attributes , Null or Not Null Default Values Primary Key References (i.e., Foreign Key) Check Constraint (i.e., Validation Rule)
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Sample Database Note 1: Parents before children Note 2: These tables are slightly different from before
Image of page 8
Employee Table CREATE TABLE tblEmployee ( FirstName Varchar(20) Not Null , MiddleName Varchar(20) Null , LastName Varchar(30) Not Null What is the difference between Char(20) and Varchar(20)? What is the difference between Varchar(20) and Varchar(MAX)?
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Employee Table - Simple PK CREATE TABLE tblEmployee ( FirstName Varchar(20) Not Null , MiddleName Varchar(20) Null , LastName Varchar(30) Not Null , EmployeeID Varchar(10) Primary Key By default, primary keys are clustered. Primary keys cannot be null. Primary keys must be unique.
Image of page 10
Employee Table - Simple PK CREATE TABLE tblEmployee ( FirstName Varchar(20) Not Null , MiddleName Varchar(20) Null , LastName Varchar(30) Not Null , EmployeeID Int Primary Key By default, primary keys are clustered.
Image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Employee Table - Simple PK
Image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern