-
1. SQL Overview.
1. What is SQL?
SQL (Structured Query Language) is the language used to operate on relational databases. It can be applied to all relational databases, such as MySQL, Oracle, SQL Server, etc.
The SQL standards (ANSI ISO) are: SQL-92: SQL language standard published in 1992; sql:
1999: SQL language tags released in 1999; sql:2003:
SQL language tags released in 2003; These standards are just like the JDK versions, and there are always some syntax changes in the new version. Different standards have been implemented in databases from different periods.
While SQL can be used in all relational databases, many databases also have some syntax that follows the standard and what we can call "dialects". For example, the limit statement in MySQL is a dialect unique to MySQL and is not supported by other databases! Of course, either Oracle or SQL Server have their own dialects.
-
What is a databaseA database is a data set that is stored in some kind of structured, sequential manner. A simple way to think of it as a database is to think of it as a school, and the school can quickly find out the student according to the grade level of the student
Tables in the database: The concept of a table can be understood as an age that is responsible for keeping all the personal information of the student. Of course, this requires a lot of tables to complete, such as:
Profiles correspond to a table, academic performance corresponds to a table, and so on. They can have a relationship with each other or not. Table:
A structured monad of a specific type of data of a Bridges species. And the names in the database all have a unique name that is used to identify themselves.
There are two basic properties of a table. Column: A field in a table.
All tables are made up of one or more columns. It can be understood that all the names of the students are saved in a column. We can use this field to find out the name of the student with the first name xx.
Rows: The data in the table is stored in rows. Every record saved is stored in its own line, through which we can probably understand the basic information of a person.
For example, each row in the Customers table stores a customer, and the row can have one field or more fields.
Primary key: Each row in the table should have a column that can uniquely identify itself, that is, how does the table distinguish whether there are duplicate records in each row? The customer table can use the customer serial number, or the name, etc. as the primary key, of course, in general, we will choose the customer number, and the order table can use the order number as the primary key.
It stands to reason that any column in a table can be used as a primary key: but in general we will follow two principles: 1: No two rows in a table have the same primary key value2:
Each row must have a primary key value (not empty);
How do we operate the database? The answer is undoubtedly SQL statements, which are not like other programming languages, they are all programming with a specific domain, and they need to distinguish between unique groups of people. But SQL statements can manipulate almost all databases, and they basically use the same commands.
The structure of the storage is the main basis for classifying the types of copy databases. In today's Internet, databases are usually divided into two categories, namely relational and non-relational databases. >>>More
Create a database.
Select the Program Management SQL Server 2008 SQL Server Management Studio command in the Start menu to open the SQL Server Management Studio window and establish a connection using Windows or SQL Server authentication. >>>More
The database is generally composed of many tables, for example, the school builds a database, which can build a student table (including the student's name, age, student number, class, date of birth), a teacher table (including the teacher's name, age, teaching class, teaching category), a report sheet (including the student's student number, and the grades of each subject), etc. These are the ways in which the files are stored in the database, and try to make sure that the items in a table are closely related and have the same attributes, if this condition cannot be met, a table must be built (the redundancy of the built table has 4 levels). In order to meet the user's query needs, we also need to make a number of views, for example, you can make a view of his items have the name of the student, age, grades of each subject, and the teacher of each subject, etc., we can also export new items according to the existing items, for the purpose of simplicity, for example, the view can add an average grade, we add different permissions and roles to each view, and provide it to different people to query to protect the security of the database. >>>More
First, the functions are different.
1. to char: Output the time and date according to the specified format, and get a string instead of the date type. >>>More
select ,from emp e left jion dept don ;
Left Company. The left link is, the left side prevails, and the right side is useless to make up for it. >>>More