sql常用语句

1.创建用户

  create user [username] identified by [password];

  grant dba to [username];(授权)

  注意:创建新用户之后,用pl/sql developer登录的时候,用户类型选normal,而不是SYSDBA,因为他不是SYSDBA角色。

2.查询

  a.查询所有的表

    select * from tab

  b.查询某一张表

    select * from [tablename]

3.创建表

  create table [tablename]([columnname] int primary key,[columnname] varchar(20))

4.列

  a.添加新列

    alter table [tablename] add [columnname] int;

  b.删除列

    alter table [tablename] drop column [columnname];

5.增删改查

  a.简单的增删改查

    insert into table_name(column1,column2) values(value1,value2)

    delete from table_name where columnN = conditionN

    update table_name set column1 = values where columnN = conditionN

    select column1,column2 from table_name where columnN = conditionN

  b.详细的增删改查

    SQL语句的增删改查(详细)

 6.创建外键

SQL> create table student(stuld number(6),name varchar2(30));

表已创建。

已用时间: 00: 00: 00.06
SQL> create table score(id number(6),stuld number(6));

表已创建。

已用时间: 00: 00: 00.06
SQL> alter table student add primary key(stuld);

表已更改。

已用时间: 00: 00: 00.18
SQL> alter table score add foreign key (stuld) references student (stuld);

表已更改。

已用时间: 00: 00: 00.06

oracle sql增强练习:

  在oracle中创建自动增长字段

  oracle常用SQL语句分享

https://zhidao.baidu.com/question/82265669.html

原文地址:https://www.cnblogs.com/johnsonwei/p/5986512.html