Preview

Learn Sql

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

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

    A database language must enable the user to create database and table structures to perform basic data management chores.…

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

    database

    • 4800 Words
    • 20 Pages

    If the table PRODUCT has a column PRICE that has the data type Numeric (8,2), the value 12345 will be displayed by the DBMS as ________.…

    • 4800 Words
    • 20 Pages
    Better Essays
  • Satisfactory Essays

    Sql Cheat Sheet

    • 594 Words
    • 3 Pages

    * NULL value in a table is a value in a field that appears to be blank…

    • 594 Words
    • 3 Pages
    Satisfactory Essays
  • Better Essays

    Topic#6: Relational Database Operators 6.1 Significance of Relational Operators • Relational database supports basic database operations in order to provide useful means for retrieving or manipulating data in tables. • Because the relational model has its mathematical basis upon the relational theory (by thinking tables as sets or relations), the supported database operators conform to existing operators in relational algebra. • In fact, a relational database software implementation, called DBMS, is said to have higher degree of relational completeness depending upon the extent to which relational algebra operators are supported.…

    • 1097 Words
    • 5 Pages
    Better Essays
  • Good Essays

    Microsoft Word

    • 540 Words
    • 3 Pages

    Place the cursor on the page where you want the new table > click the Insert Tab of the Ribbon > Click the Tables Button on the Tables Group. You can create a table with one of four ways:…

    • 540 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    References: |Single |Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038) |…

    • 6743 Words
    • 27 Pages
    Powerful Essays

Related Topics