Preview

Another Learn From It test

Good Essays
Open Document
Open Document
864 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Another Learn From It test
Creating, dropping, and altering tables in SQLite
In this part of the SQLite tutorial, we will cover the data definition language (DDL) of the SQLite database. The DDL consists of SQL statements that define the database schema. The schema is the database structure described in a formal language. In relational databases, the schema defines the tables, views, indexes, relationships, or triggers.
The SQLite supports the following three DDL statements:
CREATE
ALTER TABLE
DROP
In SQLite, the CREATE statement is used to create tables, indexes, views, and triggers. The ALTER TABLE statement changes the structure of a table. The DROP statement removes tables, indexes, views, or triggers.
Creating tables
The CREATE statement is used to create tables. It is also used to create indexes, views, and triggers.
To create a table, we give a name to a table and to its columns. Each column can have one of these data types:
NULL — The value is a NULL value
INTEGER — a signed integer
REAL — a floating point value
TEXT — a text string
BLOB — a blob of data sqlite> CREATE TABLE Testing(Id INTEGER); sqlite> .schema Testing
CREATE TABLE Testing(Id INTEGER);
We create a simple Testing table with the CREATE TABLE statement. The .schema command shows the formal definition of the table. sqlite> CREATE TABLE Testing(Id INTEGER);
Error: table Testing already exists
If we try to create a table that already exists, we get an error. Therefore the CREATE TABLE statement has an optional IF NOT EXISTS clause. With this clause nothing is done and we receive no error. sqlite> CREATE TABLE IF NOT EXISTS Testing(Id INTEGER);
We get no error message for trying to create a table that already exists.
The CREATE TABLE ... AS statement enables to create a new table based on a SELECT statement. sqlite> CREATE TABLE Cars2 AS SELECT * FROM Cars;
The above statement creates an identical table to the Cars table using a specific SELECT statement. sqlite> ATTACH

You May Also Find These Documents Helpful

  • Good Essays

    Unit 7 Lab

    • 726 Words
    • 3 Pages

    Collect and organize data for aphelion distances and perihelion distances of objects as they orbit the sun…

    • 726 Words
    • 3 Pages
    Good Essays
  • Good Essays

    In Change Request 2, Huffman Trucking had Team B to create the entities and attributes for a brand new maintenance database. And also our team has been asked to create these tables for the items it asked for. Our team used Microsoft Access, which is a database tool. First through access we created the tables we needed for the entities, then we gathered the tables with the attributes . An example of a table is called “Maintenance Work Orders”, and in that table there would be attributes like “Part ID” or “Vehicle”. In this table we know exactly of what’s on there like the Work Order number, vehicle, part ID, and etc.…

    • 820 Words
    • 4 Pages
    Good Essays
  • Good Essays

    This lab will utilize a set of tables found in the script file (LeeBooks.sql) found in the Doc Sharing area of the website. If you have not yet downloaded this file from Doc Sharing then do so now. Once you have downloaded the script file, import and run the script in SQL*Plus.…

    • 1559 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    # Select a primary key for each table as indicated in the provided ERD diagram.…

    • 694 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    Week 1 SOW 1

    • 452 Words
    • 2 Pages

    Building the Physical Database: The data model will be translated into the Relational Database Management system of choice. All Tables and Columns with specific data types will be created and will include Relational and other constraints.…

    • 452 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    Nt1330 Unit 1 Study Guide

    • 1178 Words
    • 5 Pages

    To create Schema definition: It is a database administrator responsible to installation, configuration and upgrading hardware and operating system on given database and also to decide what information to be held in database.…

    • 1178 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Lab 204 Quiz

    • 2478 Words
    • 10 Pages

    You follow certain step’s to access the supplementary readings for a course when u sing your organizations library management system. These steps that you follow are examples of the _________ components of an information system.…

    • 2478 Words
    • 10 Pages
    Satisfactory Essays
  • Satisfactory Essays

    cis3730_Exam1_Studyguide

    • 512 Words
    • 2 Pages

    Be able to give examples of tables, specify their primary keys, and explain how they are related through foreign keys.…

    • 512 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 6 True

    • 287 Words
    • 1 Page

    The FROM keyword is used in a SELECT clause to determine which columns are included in the query. FALSE…

    • 287 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Defining a(n) primary key in a second table creates a relationship between that table and the table where the primary key was first defined. _________________________…

    • 585 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    a guide to mysql ch 7

    • 1287 Words
    • 9 Pages

    During the CREATE TABLE command, but can be modified using the ADD PRIMARY KEY command…

    • 1287 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    unit 6

    • 360 Words
    • 2 Pages

    1) SQL is the programming language used to manipulate data and data objects in a relational database management system.…

    • 360 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Dbm 381 Week 1paper

    • 885 Words
    • 4 Pages

    A database consists of one or more tables; each containing data stored as individual records. Different database architectures determine how the tables and records are organized or related…

    • 885 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    04

    • 4586 Words
    • 34 Pages

    The MODIFY clause is used with the ALTER TABLE command to add a PRIMARY KEY constraint to an existing table.…

    • 4586 Words
    • 34 Pages
    Satisfactory Essays
  • Good Essays

    Sometimes we have to save image, any type of multimedia file or text file in Oracle database from client. In web application client must upload the file in web server or any other machine. But web server can access that directory where the files are uploaded. To complete the operation we can use Oracle Blob data type, Oracle directory and with a procedure.…

    • 370 Words
    • 2 Pages
    Good Essays

Related Topics