× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
g
3
3
2
J
2
p
2
m
2
h
2
s
2
r
2
d
2
l
2
a
2
New Topic  
Nica Nica
wrote...
Posts: 520
5 years ago
The following database will be used in this question:

GENERAL SALES DATABASE:

SALESREP
SalesRepNoRepNameHireDate
654Jones01/02/2005
734Smith02/03/2007
345Chen01/25/2018
434Johnson11/23/2004

CUSTOMER
CustNoCustNameBalanceSalesRepNo
9870Winston500345
8590Gonzales350434
7840Harris800654
4870Miles100345

Explain the use of the SQL statement CREATE TABLE. Do NOT discuss the ALTER statement in your answer, but DO include an example based on the SALESREP table in the General Sales database.
Textbook 
Database Processing: Fundamentals, Design, and Implementation

Database Processing: Fundamentals, Design, and Implementation


Edition: 15th
Authors:
Read 42 times
2 Replies

Related Topics

Replies
wrote...
5 years ago
The SQL statement CREATE TABLE forms the basis for all SQL table construction. CREATE TABLE is used to name tables and specify their structure, including column names and their associated data types. In addition, CREATE TABLE can be used to define primary keys, foreign keys, and to specify constraints on tables, columns and column values. There are five SQL keywords that specify these constraints: PRIMARY KEY, FOREIGN KEY, NULL/NOT NULL, UNIQUE, and CHECK. PRIMARY KEY and FOREIGN KEY are used to specify keys. NULL and NOT NULL specify whether nulls are allowed as values in a column. UNIQUE specifies whether the column values must be unique. The SQL keyword CONSTRAINT may be used to specify some of the table constraints. For example, to create the SALESREP table for the General Sales database, the following SQL statement may be used:

CREATE TABLE SALESREP (
SalesRepNoIntegerNot Null,
RepNameChar(25)Not Null,
HireDateDateNot Null,
CONSTRAINT SalesRepPK PRIMARY KEY (SalesRepNo)
);
Note to the instructor: The data type of HireDate is shown as Date, which is the ORACLE data type shown in the text. Students may also use Datetime, which is the SQL Server data type, which is also shown in the text.
Nica Author
wrote...
5 years ago
Appreciate the effort, thank you!
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1106 People Browsing
 137 Signed Up Today
Related Images
  
 126
  
 310
  
 74
Your Opinion
Which of the following is the best resource to supplement your studies:
Votes: 249