aarya 1 Junior Poster

What is a database?

A database is a collection of data stored in some organized fashion. The simplest way is to think of it is to imagine a database as a filling cabinet.

What are tables in the database?

When you want to store some file with information you just can’t toss it in the drawer. Rather you create file within the filling cabinets and then add related file in a specific files.
In the database language we call files as tables. Ale is a structured file that can store data of a specific type. A table might contain a list of customers, name, ID or any other list of information.

What are columns and data types?

Tables are made up of columns. A column contains a particular piece of information within a table. Column is single field in a table. All the tables are made up of one or more columns. Data in a table is stored in rows; each record saved is stored in its own row. Row is a record in a table

Keys

Every row in a table should have some column that uniquely identifies it. Table containing student information might use student roll number for this purpose.

What is SQL?

SQL is an abbreviation for Structured Query Language. SQL is a language designed mainly for communicating with databases. SQL is easy to learn. The statements are all made up of descriptive English word. SQL is designed to do only one work that is communicating with database in a simple and efficient way.

Creating tables

SQL is not just used for table data manipulation. Rather sql can be used to perform all database and table operations, including the creation and manipulation of tables themselves. There are two ways to create database tables:

Most DBMSs come with an administration tool that can be used to create and manage database tables interactively

Tables may also be manipulated directly with SQL statements

To create tables, CREATE TABLE sql statement is used.

Basic table creation
To create the new table you must specify the following information
The name of the new table specified after keywords CREATE TABLEM’S
The name and definition of the table columns separated by commas
Some DBMSs require that you also specify the table location
The following SQL statement creates the students table

Create table students
( 
student_name char(50) not null,
student_age char(10) not null,
student_marks car(10) not null
);

Now we will see how to insert that data into the database

As it is name suggest INSERT is used to insert (add) rows to a database table insert can be used in several ways
Inserting a full single row
Inserting single partial row
Inserting the results of a query

Inserting complete rows

The simplest way to insert data into a table is to use the basic INSERT syntax, which requires table name and the values to be inserted into a new row.

Here is the example

INSERT into student values (‘hari’,’10’,’98’);
The meaning of the above statement
INSERT into student values (‘name’,’age’,’marks’);

The above example inserts a new student into a student table. Although the syntax is simple but is not the safe methods. The above SQL statement is highly dependent on the order in which the columns are defined in the table. The safer way to write the INSERT Statement is as follows

Insert into student (student_name,student_age,student_marks) values (‘hari’,’10’,’98’);

To delete (remove) data from a table, the delete statement is used. Delete can be used in two ways.

To delete specific rows forma a table
To delete all rows from table
The following statement delete is a single row from the student table

DELETER FROM students where id=’100’;

THIS STATEMENT IS SELF EXPLANTORY. Delete form requires that you specify the name of the table form which the data is to be deleted. The WHERE Clause filters which rows are to be deleted. In this example only student whose id is 100 will be deleted. If the WHERE clause were omitted, this statement would be deleted every customer in the table.

Delete takes no columns names or wildcard characters. Delete deletes entire rows not columns

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.