To describe the process of creating a table in SQL and a list of different data types used for fields.
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:
- 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.
- 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.
- 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.
- Char(n): it Stores a character string, which is n characters long. The value for n must be an integer.
- 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?
Chapter 3 Solutions
Concepts of Database Management
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY