This document discusses how to create and manage database tables in Oracle. It describes how to create tables with columns of different data types, alter table definitions by adding or modifying columns, drop and rename tables, and add comments to tables. The key database objects like tables, views, indexes and sequences are also introduced. Common SQL statements used for managing tables like CREATE TABLE, ALTER TABLE, DROP TABLE, COMMENT and more are explained with examples.
VMWare vFabric SQLFire - scalable SQL instead of NoSQL
There is quite a bit of buzz thesedays on "NoSQL" databases. The lack of transactions and good support for querying (SQL) has been a problem for many to adopt these solutions. This talk presents, VMWare SQLFire, a distributed SQL data management solution that melds Apache Derby (borrowing SQL drivers, parsing and some aspects of the engine) and an object data grid (GemFire) to offer a horizontally scalable, memory oriented data management system where developers can continue to use SQL. We focus on new primitives that extend the well known SQL Data definition syntax for data partitioning and replication strategies but leaving the "select" and data manipulation part of SQL intact so it only minimally impacts your application.
I gave this presentation at What's next, Paris 2011(http://www.whatsnextparis.com/abouttheseminar.html).
Explained how to the handset on SQL. Explain what is a database. How to create database how to drop database how to create a table. Insert Primary Key, Foreign Key all the constraints, dates. It also explained about the Index.
VMWare vFabric SQLFire - scalable SQL instead of NoSQL
There is quite a bit of buzz thesedays on "NoSQL" databases. The lack of transactions and good support for querying (SQL) has been a problem for many to adopt these solutions. This talk presents, VMWare SQLFire, a distributed SQL data management solution that melds Apache Derby (borrowing SQL drivers, parsing and some aspects of the engine) and an object data grid (GemFire) to offer a horizontally scalable, memory oriented data management system where developers can continue to use SQL. We focus on new primitives that extend the well known SQL Data definition syntax for data partitioning and replication strategies but leaving the "select" and data manipulation part of SQL intact so it only minimally impacts your application.
I gave this presentation at What's next, Paris 2011(http://www.whatsnextparis.com/abouttheseminar.html).
Explained how to the handset on SQL. Explain what is a database. How to create database how to drop database how to create a table. Insert Primary Key, Foreign Key all the constraints, dates. It also explained about the Index.
After completing this lesson, you should be able to
do the following:
List the capabilities of SQL SELECT statements
Execute a basic SELECT statement
Differentiate between SQL statements and iSQL*Plus commands
http://phpexecutor.com
The presentation has a quick preamble on SQL injection definition, sqlmap and its key features.
I then illustrate into details common and uncommon problems and respective solutions with examples that a penetration tester faces when he wants to take advantage of any kind of web application SQL injection flaw on real world web applications, for instance SQL injection in ORDER BY and LIMIT clauses, single entry UNION query SQL injection, specific web application technologies IDS bypasses and more.
These slides have been presented at the Front Range OWASP Conference in Denver on March 5, 2009.
After completing this lesson, you should be able to do the following:
Describe the main database objects
Create tables
Describe the datatypes that can be used when specifying column definition
Alter table definitions
Drop, rename, and truncate tables
DDL. data defination language for creating databaseSHAKIR325211
data defination language database management systems how to create a databse how to insert a record and how to select a particular coloums and fields for instance select records from employee database or select fields of particular coloumns in database than wright query Similarly, the meaning of a query in database management is a request for data . If you need to access, manipulate, delete, or retrieve data from your relational database, you'll need a database query written using a specific syntax. Our SQL tutorial will teach you how to use SQL in: MySQL, SQL Server, MS Access, Oracle, Sybase, Informix, Postgres, and other database systems.If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. Here, the INSERT INTO syntax would be as follows and somany features in database management systms Data is a collection of a distinct small unit of information. It can be used in a variety of forms like text, numbers, media, bytes, etc. it can be stored in pieces of paper or electronic memory, etc.
Word 'Data' is originated from the word 'datum' that means 'single piece of information.' It is plural of the word datum.
In computing, Data is information that can be translated into a form for efficient movement and processing. Data is interchangeable. You can organize data into tables, rows, columns, and index it to make it easier to find relevant information.
Database handlers create a database in such a way that only one set of software program provides access of data to all the users.
The main purpose of the database is to operate a large amount of information by storing, retrieving, and managing data.
There are many dynamic websites on the World Wide Web nowadays which are handled through databases. For example, a model that checks the availability of rooms in a hotel. It is an example of a dynamic website that uses a database.
There are many databases available like MySQL, Sybase, Oracle, MongoDB, Informix, PostgreSQL, SQL Server, etc.
Modern databases are managed by the database management system (DBMS). 1968 was the year when File-Based database were introduced. In file-based databases, data was maintained in a flat file. Though files have many advantages, there are several limitations.
One of the major advantages is that the file system has various access methods, e.g., sequential, indexed, and random.
It requires extensive programming in a third-generation language such as COBOL, BASIC.Cloud database facilitates you to store, manage, and retrieve their structured, unstructured data via a cloud platform. This data is accessible over the Internet. Cloud databases are also called a database as service (DBaaS) because they are offered as a managed service.A NoSQL database is an approach to design such databases that can accommodate a wide variety of data models. NoSQL can handle an exte
Creating and Managing Tables -Oracle Data base Salman Memon
After completing this lesson, you should be able to
do the following:
Describe the main database objects
Create tables
Describe the data types that can be used when specifying column definition
Alter table definitions
Drop, rename, and truncate tables
http://phpexecutor.com
This slideshow aims to convey the basics of Oracle Database. This slideshow captures all the essential concepts and necessary visualizations to capture all the key concepts of Oracle RDBMS, along with providing all the essential steps to install it on your system, whether it be on Mac or Windows. Capturing all the concepts precisely and cogently, it also explains key concepts like joins in a diagrammatic fashion enabling viewers to visualize them for easier understanding and retention, along with providing them with the syntax to pick up writing simple queries.
Automated Process for Auditng in Agile - SCRUMUmair Amjad
In last decade Agile have gained significant attention in software community. Agile is focused on producing early releases of software projects and on delivering business value immediately from the beginning. Auditing and tracking is one of the most important pillars for smooth execution and delivery of software project. This research work formulates a procedure to gauge the progress of software project throughout the life cycle. It will cover details from very beginning (project kickoff) till delivery to the customer, keeping main focus on Scrum.
Data Deduplication: Venti and its improvementsUmair Amjad
Data is the primary thing which is available in digital form everywhere. To store this massive data, the storage methodology should be efficient as well as intelligent enough to find the redundant data to save. Data deduplication techniques are widely used by storage servers to eliminate the possibilities of storing multiple copies of the data. Deduplication identifies duplicate data portions going to be stored in storage systems also removes duplication in existing stored data in storage systems. Hence yield a significant cost saving. This paper is about data deduplication, taking Venti as base case discussed it in detail and also identify area of improvements in Venti which are addressed by other papers.
Exact Cell Decomposition of Arrangements used for Path Planning in RoboticsUmair Amjad
This is short overview of research paper.
We present a practical algorithm for the automatic generation of a map that describes the operation environment of an indoor mobile service robot. The input is a CAD description of a building consisting of line segments that represent the walls. The algorithm is based on the exact cell decomposition obtained when these segments are extended to infinite lines, resulting in a line arrangement. The cells are represented by nodes in a connectivity graph. The map consists of the connectivity graph and additional environmental information that is calculated for each cell. The method takes into account both the path planning and position verification requirements of the robot and has been implemented.
Multi-core processor and Multi-channel memory architectureUmair Amjad
Content of presentation:
Multi-core processors
Multi-channel memory architecture
Comparison between single and multi channel memory
Conclusion
References
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
20 Comprehensive Checklist of Designing and Developing a WebsitePixlogix Infotech
Dive into the world of Website Designing and Developing with Pixlogix! Looking to create a stunning online presence? Look no further! Our comprehensive checklist covers everything you need to know to craft a website that stands out. From user-friendly design to seamless functionality, we've got you covered. Don't miss out on this invaluable resource! Check out our checklist now at Pixlogix and start your journey towards a captivating online presence today.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
2. 10-2
Objectives
After completing this lesson, you shouldAfter completing this lesson, you should
be able to do the following:be able to do the following:
• Describe the main database objects
• Create tables
• Describe the datatypes that can be used
when specifying column definition
• Alter table definitions
• Drop, rename, and truncate tables
3. 10-3
Database Objects
Object Description
Table Basic unit of storage; composed of rows
and columns
View Logically represents subsets of data from
one or more tables
Sequence Generates primary key values
Index Improves the performance of some queries
Synonym Gives alternative names to objects
4. 10-4
Naming Conventions
• Must begin with a letter
• Can be 1–30 characters long
• Must contain only A–Z, a–z, 0–9, _, $,
and #
• Must not duplicate the name of another
object owned by the same user
• Must not be an Oracle Server reserved
word
5. 10-5
The CREATE TABLE Statement
• You must have :
– CREATE TABLE privilege
– A storage area
• You specify:
– Table name
– Column name, column datatype, and
column size
CREATE TABLE [schema.]table
(column datatype [DEFAULT expr][, ...]);
6. 10-6
Referencing Another User’s
Tables
• Tables belonging to other users are not
in the user’s schema.
• You should use the owner’s name as a
prefix to the table.
7. 10-7
The DEFAULT Option
• Specify a default value for a column during
an insert.
… hiredate DATE DEFAULT SYSDATE, …
• Legal values are literal value, expression,
or SQL function.
• Illegal values are another column’s name or
pseudocolumn.
• The default datatype must match the
column datatype.
8. 10-8
Creating Tables
SQL> CREATE TABLE dept
2 (deptno NUMBER(2),
3 dname VARCHAR2(14),
4 loc VARCHAR2(13));
Table created.Table created.
• Create the table.
• Confirm table creation.
SQL> DESCRIBE dept
Name Null? Type
--------------------------- -------- ---------
DEPTNO NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
9. 10-9
Tables in the Oracle Database
• User Tables
– Collection of tables created and
maintained by the user
– Contain user information
• Data Dictionary
– Collection of tables created and
maintained by the Oracle server
– Contain database information
10. 10-10
Querying the Data Dictionary
• Describe tables owned by the user.
• View distinct object types owned by the
user.
• View tables, views, synonyms, and
sequences owned by the user.
SQL> SELECT *
2 FROM user_tables;
SQL> SELECT DISTINCT object_type
2 FROM user_objects;
SQL> SELECT *
2 FROM user_catalog;
11. 10-11
Datatypes
Datatype Description
VARCHAR2(size) Variable-length character data
CHAR(size) Fixed-length character data
NUMBER(p,s) Variable-length numeric data
DATE Date and time values
LONG Variable-length character data
up to 2 gigabytes
CLOB Single-byte character data up to 4
gigabytes
RAW and LONG RAW Raw binary data
BLOB Binary data up to 4 gigabytes
BFILE Binary data stored in an external
file; up to 4 gigabytes
12. 10-12
Creating a Table
by Using a Subquery
• Create a table and insert rows by
combining the CREATE TABLE statement
and AS subquery option.
• Match the number of specified columns
to the number of subquery columns.
• Define columns with column names and
default values.
CREATE TABLE table
[(column, column...)]
AS subquery;
13. 10-13
Creating a Table
by Using a Subquery
Name Null? Type
---------------------------- -------- -----
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
ANNSAL NUMBER
HIREDATE DATE
Name Null? Type
---------------------------- -------- -----
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
ANNSAL NUMBER
HIREDATE DATE
SQL> DESCRIBE dept30
SQL> CREATE TABLE dept30
2 AS
3 SELECT empno, ename, sal*12 ANNSAL, hiredate
4 FROM emp
5 WHERE deptno = 30;
Table created.Table created.
14. 10-14
The ALTER TABLE Statement
Use the ALTER TABLE statement to:Use the ALTER TABLE statement to:
• Add a new column
• Modify an existing column
• Define a default value for the new column
ALTER TABLE table
ADD (column datatype [DEFAULT expr]
[, column datatype]...);
ALTER TABLE table
MODIFY (column datatype [DEFAULT expr]
[, column datatype]...);
15. 10-15
Adding a Column
DEPT30DEPT30
EMPNO ENAME ANNSAL HIREDATE
------ ---------- --------
7698 BLAKE 34200 01-MAY-81
7654 MARTIN 15000 28-SEP-81
7499 ALLEN 19200 20-FEB-81
7844 TURNER 18000 08-SEP-81
...
“…“…add aadd a
newnew
columncolumn
intointo
DEPT30DEPT30
table…”table…”
DEPT30DEPT30
EMPNO ENAME ANNSAL HIREDATE
------ ---------- --------
7698 BLAKE 34200 01-MAY-81
7654 MARTIN 15000 28-SEP-81
7499 ALLEN 19200 20-FEB-81
7844 TURNER 18000 08-SEP-81
...
JOB
JOB
New columnNew column
16. 10-16
Adding a Column
• You use the ADD clause to add columns.
EMPNO ENAME ANNSAL HIREDATE JOB
--------- ---------- --------- --------- ----
7698 BLAKE 34200 01-MAY-81
7654 MARTIN 15000 28-SEP-81
7499 ALLEN 19200 20-FEB-81
7844 TURNER 18000 08-SEP-81
...
6 rows selected.
EMPNO ENAME ANNSAL HIREDATE JOB
--------- ---------- --------- --------- ----
7698 BLAKE 34200 01-MAY-81
7654 MARTIN 15000 28-SEP-81
7499 ALLEN 19200 20-FEB-81
7844 TURNER 18000 08-SEP-81
...
6 rows selected.
SQL> ALTER TABLE dept30
2 ADD (job VARCHAR2(9));
Table altered.Table altered.
• The new column becomes the last column.
17. 10-17
Modifying a Column
• You can change a column’s datatype,
size, and default value.
• A change to the default value affects
only subsequent insertions to the table.
ALTER TABLE dept30
MODIFY (ename VARCHAR2(15));
Table altered.Table altered.
18. 10-18
Dropping a Table
• All data and structure in the table is
deleted.
• Any pending transactions are
committed.
• All indexes are dropped.
• You cannot roll back this statement.
SQL> DROP TABLE dept30;
Table dropped.Table dropped.
19. 10-19
Changing the Name of an Object
• To change the name of a table, view,
sequence, or synonym, you execute the
RENAME statement.
• You must be the owner of the object.
SQL> RENAME dept TO department;
Table renamed.Table renamed.
20. 10-20
Truncating a Table
• The TRUNCATE TABLE statement:
– Removes all rows from a table
– Releases the storage space used by
that table
• You cannot roll back row removal when
using TRUNCATE.
• Alternatively, you can remove rows by
using the DELETE statement.
SQL> TRUNCATE TABLE department;
Table truncated.Table truncated.
21. 10-21
Adding Comments to a Table
• You can add comments to a table or
column by using the COMMENT
statement.
• Comments can be viewed through the
data dictionary views.
– ALL_COL_COMMENTS
– USER_COL_COMMENTS
– ALL_TAB_COMMENTS
– USER_TAB_COMMENTS
SQL> COMMENT ON TABLE emp
2 IS 'Employee Information';
Comment created.Comment created.
22. 10-22
Summary
Statement Description
CREATE TABLE Creates a table
ALTER TABLE Modifies table structures
DROP TABLE Removes the rows and table structure
RENAME Changes the name of a table, view,
sequence, or synonym
TRUNCATE Removes all rows from a table and
releases the storage space
COMMENT Adds comments to a table or view
23. 10-23
Practice Overview
• Creating new tables
• Creating a new table by using the
CREATE TABLE AS syntax
• Modifying column definitions
• Verifying that the tables exist
• Adding comments to a tables
• Dropping tables
• Altering tables
Editor's Notes
Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total
Lesson Aim In this lesson, you will learn about main database objects and their relationships to each other. You will also learn how to create, alter, and drop tables.
Database Objects An Oracle database can contain multiple data structures. Each structure should be outlined in the database design so that it can be created during the build stage of database development. Table: Stores data View: Subset of data from one or more tables Sequence: Generates primary key values Index: Improves the performance of some queries Synonym: Gives alternative names to objects Oracle8 Table Structures Tables can be created at any time, even while users are using the database. You do not need to specify the size of any table. The size is ultimately defined by the amount of space allocated to the database as a whole. It is important, however, to estimate how much space a table will use over time. Table structure can be modified online. Note: More database objects are available but are not covered in this course. Class Management Note Tables can have up to 1,000 columns and must conform to standard database object-naming conventions. Column definitions can be omitted when using the AS subquery clause. Tables are created without data unless a query is specified. Rows are usually added by using INSERT statements.
Naming Rules Name database tables and columns according to the standard rules for naming any Oracle database object: Table names and column names must begin with a letter and can be 1–30 characters long. Names must contain only the characters A–Z, a–z, 0–9, _ (underscore), $, and # (legal characters, but their use is discouraged). Names must not duplicate the name of another object owned by the same Oracle Server user. Names must not be an Oracle Server reserved word. Naming Guidelines Use descriptive names for tables and other database objects. Name the same entity consistently in different tables. For example, the department number column is called DEPTNO in both the EMP table and the DEPT table. Note: Names are case insensitive. For example, EMP is treated as the same name as eMP or eMp. For more information, see Oracle Server SQL Reference, Release 8, “Object Names and Qualifiers.”
The CREATE TABLE Statement Create tables to store data by executing the SQL CREATE TABLE statement. This statement is one of the data definition language ( DDL) statements, which are covered in subsequent lessons. DDL statements are a subset of SQL statements used to create, modify, or remove Oracle8 database structures. These statements have an immediate effect on the database, and they also record information in the data dictionary. To create a table, a user must have the CREATE TABLE privilege and a storage area in which to create objects. The database administrator uses data control language (DCL) statements, which are covered in a later lesson, to grant privileges to users. In the syntax: schema is the same as the owner’s name table is the name of the table DEFAULT expr specifies a default value if a value is omitted in the INSERT statement column is the name of the column datatype is the column’s datatype and length For more information, see Oracle Server SQL Reference, Release 8, “CREATE TABLE.”
Referencing Another User’s Tables A schema is a collection of objects. Schema objects are the logical structures that directly refer to the data in a database. Schema objects include tables, views, synonyms, sequences, stored procedures, indexes, clusters, and database links. If a table does not belong to the user, the owner’s name must be prefixed to the table.
The DEFAULT Option A column can be given a default value by using the DEFAULT option. This option prevents null values from entering the columns if a row is inserted without a value for the column. The default value can be a literal, an expression, or a SQL function, such as SYSDATE and USER, but the value cannot be the name of another column or a pseudocolumn, such as NEXTVAL or CURRVAL. The default expression must match the datatype of the column.
Creating Tables The example on the slide creates the DEPT table, with three columns—namely, DEPTNO, DNAME, and LOC. It further confirms the creation of the table by issuing the DESCRIBE command. Since creating a table is a DDL statement, an automatic commit takes place when this statement is executed.
Tables in the Oracle Database User tables are tables created by the user, such as EMP, that contain user information. There is another collection of tables and views in the Oracle database known as the data dictionary . This collection is created and maintained by the Oracle Server and contains information about the database. All data dictionary tables are owned by the SYS user. The base tables are rarely accessed directly because the information in them is not easy to understand. Therefore, users typically access data dictionary views because the information is presented in a format that is easier to understand. Information stored in the data dictionary include names of the Oracle Server users, privileges granted to users, database object names, table constraints, and auditing information. There are four categories of data dictionary views; each category has a distinct prefix which reflects their intended use.
Querying the Data Dictionary You can query the data dictionary tables to view various database objects owned by you. The data dictionary tables frequently used are these: USER_TABLES USER_OBJECTS USER_CATALOG Note: USER_CATALOG has a synonym called CAT. You can use this synonym instead of USER_CATALOG in SQL statements. SQL> SELECT * 2 FROM CAT; Class Management Note (For slide 10-11) Oracle8 introduces large object (LOB) datatypes that can store large and unstructured data such as text, image, video, and spatial data, up to 4 gigabytes in size.
Datatypes
Creating a Table from Rows in Another Table A second method to create a table is to apply the AS subquery clause to both create the table and insert rows returned from the subquery. In the syntax: table is the name of the table. column is the name of the column, default value, and integrity constraint. subquery is the SELECT statement that defines the set of rows to be inserted into the new table. Guidelines The table will be created with the specified column names, and the rows retrieved by the SELECT statement will be inserted into the table. The column definition can contain only the column name and default value. If column specifications are given, the number of columns must equal the number of columns in the subquery SELECT list. If no column specifications are given, the column names of the table are the same as the column names in the subquery.
Creating a Table from Rows in Another Table (continued) The slide example creates a table, DEPT30, that contains details of all the employees working in department 30. Notice that the data for the DEPT30 table is coming from the EMP table. You can verify the existence of a database table and check column definitions by using the SQL*Plus DESCRIBE command. Give a column alias when selecting an expression.
ALTER TABLE Statement After you create your tables, you may need to change the table structures because you omitted a column or your column definition needs to be changed. You can do this by using the ALTER TABLE statement. You can add columns to a table by using the ALTER TABLE statement with the ADD clause. In the syntax: table is the name of the table column is the name of the new column datatype is the datatype and length of the new column DEFAULT expr specifies the default value for a new column You can modify existing columns in a table by using the ALTER TABLE statement with the MODIFY clause. Note: The slide gives the abridged syntax for ALTER TABLE. More about ALTER TABLE is covered in a subsequent lesson.
Adding a Column The graphic adds the JOB column to DEPT30 table. Notice that the new column becomes the last column in the table.
Guidelines for Adding a Column You can add or modify columns, but you cannot drop them from a table. You cannot specify where the column is to appear. The new column becomes the last column. The example on the slide adds a column named JOB to the DEPT30 table. The JOB column becomes the last column in the table. Note: If a table already contains rows when a column is added, then the new column is initially null for all the rows. Class Management Note Oracle8i provides new options for the ALTER TABLE command, including the ability to drop a column from a table.
Modifying a Column You can modify a column definition by using the ALTER TABLE statement with the MODIFY clause. Column modification can include changes to a column’s datatype, size, and default value. Guidelines Increase the width or precision of a numeric column. Decrease the width of a column if the column contains only null values or if the table has no rows. Change the datatype if the column contains null values. Convert a CHAR column to the VARCHAR2 datatype or convert a VARCHAR2 column to the CHAR datatype if the column contains null values or if you do not change the size. A change to the default value of a column affects only subsequent insertions to the table.
Dropping a Table The DROP TABLE statement removes the definition of an Oracle8 table. When you drop a table, the database loses all the data in the table and all the indexes associated with it. Syntax where: table is the name of the table Guidelines All data is deleted from the table. Any views and synonyms will remain but are invalid. Any pending transactions are committed. Only the creator of the table or a user with the DROP ANY TABLE privilege can remove a table. The DROP TABLE statement, once executed, is irreversible. The Oracle Server does not question the action when you issue the DROP TABLE statement. If you own that table or have a high-level privilege, then the table is immediately removed. All DDL statements issue a commit, therefore making the transaction permanent. DROP TABLE table;
Renaming a Table Additional DDL statements include the RENAME statement, which is used to rename a table, view, sequence, or a synonym. Syntax RENAME old_name TO new_name; where: old_name is the old name of the table, view, sequence, or synonym new_name is the new name of the table, view, sequence, or synonym You must be the owner of the object that you rename.
Truncating a Table Another DDL statement is the TRUNCATE TABLE statement, which is used to remove all rows from a table and to release the storage space used by that table. When using the TRUNCATE TABLE statement, you cannot rollback row removal. Syntax TRUNCATE TABLE table ; where: table is the name of the table You must be the owner of the table or have DELETE TABLE system privileges to truncate a table. The DELETE statement can also remove all rows from a table, but it does not release storage space.
Adding a Comment to a Table You can add a comment of up to 2,000 bytes about a column, table, view, or snapshot by using the COMMENT statement. The comment is stored in the data dictionary and can be viewed in one of the following data dictionary views in the COMMENTS column: ALL_COL_COMMENTS USER_COL_COMMENTS ALL_TAB_COMMENTS USER_TAB_COMMENTS Syntax where: table is the name of the table column is the name of the column in a table text is the text of the comment You can drop a comment from the database by setting it to empty string ( '' ). COMMENT ON TABLE table | COLUMN table.column IS ' text ' ; SQL> COMMENT ON TABLE emp IS ' ' ;
CREATE TABLE Create a table. Create a table based on another table by using a subquery. ALTER TABLE Modify table structures. Change column widths, change column datatypes, and add columns. DROP TABLE Remove rows and a table structure. Once executed, this statement cannot be rolled back. RENAME Rename a table, view, sequence, or synonym. TRUNCATE Remove all rows from a table and release the storage space used by the table. The DELETE statement removes only rows. COMMENT Add a comment to a table or a column. Query the data dictionary to view the comment.
Practice Overview Create new tables by using the CREATE TABLE statement. Confirm that the new table was added to the database. Create the syntax in the command file, and then execute the command file to create the table. Class Management Note The reference to ‘Char’ as the datatype for columns in the lab exercises only indicate ‘character in type,’ not the CHAR datatype. Advise the students to use VARCHAR2 as the datatype for character columns.