EBK CONCEPTS OF DATABASE MANAGEMENT
EBK CONCEPTS OF DATABASE MANAGEMENT
8th Edition
ISBN: 8220100706004
Author: Last
Publisher: Cengage Learning US
Question
Book Icon
Chapter 3, Problem 1RQ
To determine

To describe the process of creating a table in SQL and a list of different data types used for fields.

Expert Solution & Answer
Check Mark

Explanation of Solution

In SQL CREATE TABLE command is used for making the table, and to describe its layout.

The syntax for creating the table:

CREATE TABLE table_name (column1 datatype, …., column n datatype);

For example, following command will create an employee table with two fields EmployeeID and EmployeeName.

CREATE TABLE Employee (EmployeeId int, EmployeeName varchar (10));

Rules for naming tables and columns in SQL vary slightly from one version of SQL to another version. Some common rules for naming tables and columns in DBMS are as follows:

• The names should not contain more than18 characters.

• Names must start with a letter.

• Names can only contain letters, numbers, and underscores ().

• it does not contain spaces.

List of data types used for field:

  1. Integer: it stores an integer, i.e., the number without decimal part. The valid data range for integer is −2147483648 to 2147483647. There is no need to specify the length of an integer.
  2. Smallint: it Stores integers but it, uses less storage space than the integer data type. The valid data range is −32768 to 32767. Sometimes, smallint is a better choice than integer when we have a certain field that will store numbers within the indicated range.
  3. Decimal (a, b): It stores a decimal number having a number of places before decimal and bnumber of places after decimal. For example, decimal (6,2) represents a six-digit number with three places to the left and two places to the right of the decimal. Most commonly, decimals, are used to represent either the currency or the number data type.
  4. Char(n): it Stores a character string, which is n characters long. The value for n must be an integer.
  5. Date: it Stores dates in the form DD-MON-YYYY or MM/DD/YYYY. For example, May 12, 2019, could be stored as 12-MAY-2019 or 5/12/2019.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Text book image
Oracle 12c: SQL
Computer Science
ISBN:9781305251038
Author:Joan Casteel
Publisher:Cengage Learning
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Cengage Learning
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning