We can insert some data in sqlplus to facilitate subsequent query operations.
After opening sqlplus and establishing a successful connection, enter the following commands one‑by‑one right after the SQL > prompt.
Tables consist of rows and columns. Example:
Basic SELECT Syntax
SELECT
column1,
column2,
...
FROM
tablename;Code language: SQL (Structured Query Language) (sql)
Query the student table
- Query a single column
- Query multiple columns
- Query all columns
- Use asterisk
*to query all columns
Insert Sample Data
SQL> insert into student(id, name, sex) values(1,'Tom','Male');
1 row created.
SQL> insert into student(id, name, sex) values(2,'Jack','Male');
1 row created.
SQL> insert into student(id, name, sex) values(3,'Lucy','Female');
1 row created.Code language: JavaScript (javascript)
Oracle environment hint: 1 row created. means the insertion succeeded.
Query All Columns Using Asterisk *
SQL> select * from student;
ID NAME SEX
---------- ---------------- ----
1 Tom Male
2 Jack Male
3 Lucy FemaleCode language: JavaScript (javascript)
Query Single Column (name)
SQL> select name from student;
NAME
----------------
Tom
Jack
LucyCode language: JavaScript (javascript)
Query Multiple Columns (id, name)
SQL> select id, name from student;
ID NAME
---------- ----------------
1 Tom
2 Jack
3 LucyCode language: JavaScript (javascript)
Table insertion and query
Previous: Create table
Next: Sorting