ddl

mysql学习-DDL语句

匿名 (未验证) 提交于 2019-12-02 22:02:20
sql基本概念 什么是sql? Structured Query Language 结构化查询语言 通俗来说就是定义了 操作所有关系型数据库(如mysql,oracle,sqlserver等)的规则 每一种操作数据库的方式存在不一样的地方,类似于"方言". sql通用语法 sql语句可以单行或多行书写,以分号结尾. 例如:(在 cmd 黑窗口下) 查看所有数据库名称: SHOW DATABASES ;(切记后面要加 s ). 查看数据库物理存放位置: show global variables like "%datadir%" . 可使用空格和缩进来增强语句可读性. mysql语句中的sql不区分大小写,但是关键字建议大写. 有3种注释:(cmd窗口下) 单行注释: 注释内容(mysql特有) 注意 -- 符号后面有一个空格, # 后面有没有空格都行. 多行注释: /* 注释内容 */ sql分类 DDL(Data Definition Language)数据定义语言 用来定义数据库对象: 比如数据库,表,视图等. 关键字: create, drop, alter等. DML(Data Manipulation Language)数据操作语言 用来对数据库中表的数据进行增删改. 关键字:update, insert, delete等. DQL(Data Query Language

What is a good Visio Enterprise Architect replacement? [closed]

社会主义新天地 提交于 2019-12-02 21:29:18
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. I've been using Visio 2002/2003 Enterprise Architect to do my database schema design visually and then forward-generate the DDL to create the database. I wanted to switch to Visio 2007, but while it does have database diagramming support, it doesn't have the ability to generate DDL. Bummer. I am really disappointed because it seems like Microsoft has completely abandoned this feature. You can't do it in Visual Studio

hive查询语句入门(hive DDL)

只谈情不闲聊 提交于 2019-12-02 21:09:34
hive DDL 启动hadoop /apps/hadoop/sbin/start-all.sh 开启MySQL库,用于存放hive的元数据 sudo service mysql start 启动hive hive 在/data/hive3下下载数据库数据 mkdir /data/hive3 cd data/hive3 wget http://192.168.1.100:60000/allfiles/hive3/buyer_log wget http://192.168.1.100:60000/allfiles/hive3/buyer_favorite 在hive中创建数据库并以'\t'为分隔符 create table buyer_log(id string,buyer_id string,dt string,ip string,opt_type string) row format delimited fields terminated by '\t' stored as textfile; 将/data/hive3下的数据导入到hive中 load data local inpath '/data/hive3/buyer_log' into table buyer_log; load data local inpath '/data/hive3/buyer_favorite'

day11:DML语言和DDL语言

放肆的年华 提交于 2019-12-02 18:26:17
DML:数据操作语言: insert 插入 ; update 修改 ; delete 删除 一、插入语句 语法: insert into 表名(列名,...) values(值1,...); 1、插入的值的类型要与列的类型一致或兼容 2、不可以为null的列必须插入值,可以为null的列有下列两种方式不插入值 方式一: insert into 表名(列名1,列名2,...) values(值1,null,...); 方式二:可以为null的列不给列名,就可以不插入值 3、列的顺序可以调换 4、列的个数和值的个数必须一致 5、可以省略列名,默认所有列,而且列的顺序和表的顺序一致 6、批量插入语句 insert into 表名 values(值1,值2,值3,...),(值1,值2,值3,...),(值1,值2,值3,...),...; 二、修改语句 语法:update 表名 set 列=新值,列=新值,... where 筛选条件; 三、删除语句 语法:delete from 表名 where 筛选条件; DDL:数据定义语言 库和表的管理 创建:create 修改: alter 删除: drop 一、库的管理 创建、修改、删除 1、库的创建 语法:create database 库名; 2、更改字符集 语法:alter database 库名 character set 字符集;

Why can't I write DDL directly after a PLSQL anonymous block?

社会主义新天地 提交于 2019-12-02 16:51:37
问题 I have the following simple script. declare begin null; end; create table &&DB_SCHEMA..test_table ( test_column varchar(20) ); Executing it ends with the following error ORA-06550: line 6, column 1: PLS-00103: Encountered the symbol "CREATE" 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action: Can't I use the DDL directly after an anonymous block? Am I forced to do it with EXECUTE IMMEDIATE inside the anonymous block? 回答1: You are simply missing a '/': SQL>

How to generate DDL for all tables in a database in MySQL

给你一囗甜甜゛ 提交于 2019-12-02 16:33:19
How to generate the DDL for all tables in a database of MySQL at once. I know that the following query will output the DDL for a table. But I want DDL of all tables at once because I am having hundreds of tables in my database. show create table <database name>.<table name>; For example: show create table projectdb.customer_details; The above query will result in DDL of customer_details table. I am using MySQL with MySQL workbench on Windows OS. AJ. You can do it using the mysqldump command line utility: mysqldump -d -u <username> -p<password> -h <hostname> <dbname> The -d option means

Unit testing DDL statements that need to be in a transaction

删除回忆录丶 提交于 2019-12-02 11:01:06
I am working on an application that uses Oracle's built in authentication mechanisms to manage user accounts and passwords. The application also uses row level security. Basically every user that registers through the application gets an Oracle username and password instead of the typical entry in a "USERS" table. The users also receive labels on certain tables. This type of functionality requires that the execution of DML and DDL statements be combined in many instances, but this poses a problem because the DDL statements perform implicit commits. If an error occurs after a DDL statement has

Table cannot be created in mysql -Error 1064

我是研究僧i 提交于 2019-12-02 07:15:48
I am trying to create a table in MySQL with the query CREATE TABLE ofRosterGroups ( rosterID BIGINT NOT NULL, rank TINYINT NOT NULL, groupName VARCHAR(255) NOT NULL, PRIMARY KEY (rosterID, rank), INDEX ofRosterGroup_rosterid_idx (rosterID) ); but seems like it is throwing error everytime I made updates too. I don't know what is going wrong with it. Error coming up is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank TINYINT NOT NULL, groupName VARCHAR at line 3 MySQL 8.0.2 added support for the window

SQL结构化查询语——之DDL语言

▼魔方 西西 提交于 2019-12-01 23:39:17
一、SQL结构化查询语言概述 SQL是关系型数据库所使用的标准语言,最初是基于IBM的实现在1986年被批准的。1987年,“国际标准化组织(ISO)”把ANSI(美国国家标准化组织) SQL作为国际标准。 1. SQL语言规范 在数据库系统中,SQL语句关键词不区分大小写(建议用大写) 数据库的资源对象是区分大小写的,如表、数据库这类资源在操作系统中以独立文件形来存储,如果文件系统对文件命名区分大小写则SQL语言内引用资源对象 资源内的元素不区分大小写,如:表的字段名称不区分大小写,因为在操作系统中不是独立的文件。 SQL语句可单行或多行书写,以“;”结尾。 关键词不能跨多行或简写。 用空格和缩进来提高语句的可读性(但并不强制)。 子句通常位于独立行,便于编辑,提高可读性()。 2. 注释: 注释类型 注释符号 说明 标准 单行注释 -- --与注释内容之间有空格 SQL标准 多行注释 /* 多行内容被/*包裹 SQL标准 单行注释 # 多行内容被#包裹 MYSQL标准 3.SQL语言分类 >DDL: Data Defination Language 数据定义语言 CREATE,DROP,ALTER >DML: Data Manipulation Language 数据操纵语言 INSERT,DELETE,UPDATE >DQL:Data Query Language

Drop or create database from stored procedure in PostgreSQL

╄→尐↘猪︶ㄣ 提交于 2019-12-01 20:45:43
I have a function that looks like this: BEGIN DROP DATABASE IF EXISTS db_1; END; I'm getting the following error: ERROR: DROP DATABASE cannot be executed from a function or multi-command string. Is it not possible to drop a database from a stored procedure in PostgreSQL? I'm using plpgsql. Erwin Brandstetter The error message is just a s clear as the manual on this: DROP DATABASE cannot be executed inside a transaction block. A plgpsql function is surrounded by a transaction block automatically. The long and the short of it: you cannot do that - directly. Is there a particular reason you can't