Preview

Learn Sql From Begins

Good Essays
Open Document
Open Document
864 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Learn Sql From Begins
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

    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

    The SELECT statement is the primary means of extracting data from database tables, and allows you to determine exactly which data you want to extract by means of different comparison operators used in the WHERE clause. This includes the use of specific "wild card" characters which allow you to search for character or number patterns within the data. You can also perform mathematical expressions within the SELECT statement to create derived output. The ORDER BY clause allows you to sort the output data in either ascending (the default) or descending order. Lab #5 will explore all of these applications of the SELECT statement.…

    • 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
  • Satisfactory Essays

    Creating tables in the graphical interface is not the only way to create a table. It is also possible to create the table using the SQL programming language.…

    • 327 Words
    • 2 Pages
    Satisfactory 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

    Understand the three components of a basic select statement and what do they mean (select, from, where).…

    • 512 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 6 True

    • 287 Words
    • 1 Page

    The * in SELECT * clause of an SQL statement is a wildcard for returning all columns in a table. TRUE…

    • 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
  • Satisfactory Essays

    unit 6

    • 360 Words
    • 2 Pages

    6) The * in SELECT * clause of an SQL statement is a wildcard for returning all columns in a table.…

    • 360 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    The SQL command that lets you insert data into a table, one row at a time, is…

    • 1917 Words
    • 8 Pages
    Powerful 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

    Kudler Fine Foods wants to convert the Chart of Accounts sheet in Excel to an SQL database. In order to do so, it is important to format the excel data in proper SQL tables. Normalization plays an important part in placing data fields in proper tables.…

    • 480 Words
    • 2 Pages
    Good Essays

Related Topics